获取资源阅读器
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream;/**来自 N o w J a v a . c o m - 时 代 Java**/ import java.io.InputStreamReader; import java.io.Reader; public class Main { public static void main(String[] argv) throws IOException { Object caller = "nowjava.com"; String resourceName = "nowjava.com"; System.out.println(getResourceReader(caller, resourceName)); } public static Reader getResourceReader(final Object caller, final String resourceName) throws IOException { BufferedReader in = null; if (caller == null) { throw new IllegalArgumentException("caller is null"); } try { final InputStream stream = caller.getClass().getClassLoader().getResourceAsStream(resourceName); /* from N o w J a v a . c o m*/ if (stream == null) { throw new java.lang.IllegalArgumentException("irresolvable resource " + resourceName); } in = new BufferedReader(new InputStreamReader(stream, "8859_1")); }