Wednesday, July 02, 2008
Little Java Quiz - File loaded from classpath
Given:
(Don't peek if you want to give it a try!)
Answer:
- a file with a given name;
- the file is located in the file system;
- the file can be loaded via the classpath;
(Don't peek if you want to give it a try!)
Answer:
String filePath = Thread.currentThread()
.getContextClassLoader()
.getResource(filename)
.getFile();