Posted on

Resource file not found

File file = new File(getClass().getResource("resourceFile.txt").getFile());

but the file doesn’t exist.

It turned out the problem was due to spaces in my path

I found two solutions:

org.apache.commons.io.FileUtils.toFile(myClass().getResource("resourceFile.txt")‌​);
myClass().getResource("resourceFile.txt")‌​.toURI();
Leave a Reply

Your email address will not be published. Required fields are marked *