Java: Read File From Resource

(Last Updated On: )

If you want to read a file from the resources folder it is pretty straight forward.

import java.io.File;

ClassLoader loader = getClass().getClassLoader();
File file = new File(loader.getResource(myFileName).getFile());