Java Class.getResourceAsStream to Accessing Resources in a Location-Independent

Friday, July 9th, 2010

Do you ever have this problem or not.
Often, you need to refer to the Resource.
You often see a problem about Path
ThisĀ  content can help you to Accessing Resources in a Location-Independent
Class.getResourceAsStream(fileName) Can help you when you put Resoruce in the same Class Path
Example Code

package pkg;

import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;

class Test {

[...]