I was reading a recent post about how to access a text file in the root of a web-app when I remembered something I read in Charles Lyons book.He mentioned that getResource and getResourceAsStream have J2SE counterparts in the io package.If so,why would one use the J2EE methods over the J2SE methods and vice versa??
This method is different from java.lang.Class.getResourceAsStream, which uses a class loader. This method allows servlet containers to make a resource available to a servlet from any location, without using a class loader.
Ok...I read the bit about classloaders.So I just need to know that the J2SE version wont work on distributed apps.
Joined: Feb 22, 2009
Scrap that distributed application idea. I looked into your question and I guess the only difference is that java.lang.Class.getResourceAsStream can only access resources in the directory or jar file from which the class was loaded from whereas the other method can get resources anywhere in the container. See this