Java - class.getResource返回null [英] Java - class.getResource returns null

查看:289
本文介绍了Java - class.getResource返回null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下命令获取此特定文件的URL,但它返回null。有没有人对问题或其他方法有任何建议?

I am using the following to get the URL of this particular file, but it returns null. Does anyone have any suggestions as to the problem or an alternate way to do this?

URL url = ExchangeInterceptor.class.getResource("GeoIP.dat");


推荐答案

对于那些使用 Intellij Idea :检查设置 - >编译器 - >资源模式

该设置包含应解释为资源的所有扩展。如果扩展不符合此处的任何模式,则class.getResource将使用此扩展名为资源返回null。

The setting contains all extensions that should be interpreted as resources. If an extension does not comply to any pattern here, class.getResource will return null for resources using this extension.

这篇关于Java - class.getResource返回null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆