[英]why is my `getClass().getResource(“logs”)` returns null?
You're looking for a resource which is relative to the LogUtils
class. 您正在寻找与
LogUtils
类相关的资源。
You could use getClass().getResource("/logs")
or you could use getClass().getClassLoader().getResource("logs")
. 您可以使用
getClass().getResource("/logs")
,也可以使用getClass().getClassLoader().getResource("logs")
。
(In either case, I'm not 100% convinced it'll work when that's a folder rather than an actual resource...) (无论哪种情况,我都不是100%确信当它是文件夹而不是实际资源时它会工作...)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.