DJUTILS - Delft Java Utilities  

URLResource class

The URLResource class helps to quickly find the location of a resource under different circumstances. Included retrieval possibilities are:

In order to retrieve a file for the above situations, URLResource tries different approaches with try ... catch to see if it can find the file. The sequence is as follows:

The getResource(filename, base) method uses the above methods to find the file relative to the given base directory or location.

The getResourceAsStream(name) method uses the above methods to find the file, and return it as an InputStream to read from.