I have this code:
this.fileName = getClass().getResource("logs").toURI().toString();
which fails for null pointer exception because getClass().getResource("logs")
returns null
what am I missing?
You're looking for a resource which is relative to the LogUtils
class.
You could use getClass().getResource("/logs")
or you could use 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...)
See more on this question at Stackoverflow