Friday, November 2, 2007

Resource files in Java

Just as we have resource files when developing with .NET, Java can read from resource files located in a directory listed for the class path.

You can use one of the following two statements depending on the context from which you want to read the resource file:

("filename"); //to call from a static context

this.getClass().getResourceAsStream("filename"); //to call from a non-static context

No comments: