类文件路径就是使用了classpath的路径找对应的资源文件,即src路径。与“相对路径”比较:能够通过“set classpath=路径 ” 这方式指定类文件路径,这样在不同盘符下执行java文件就不会报错
 注意事项:classpath路径中"/"是指在src文件路径(src),并非值项目路径
public class ClassPath {
    public static void main(String[] args) throws Exception {
        Class clazz = ClassPath.class;
        //找到该class所在src目录下的hello.txt文件
        InputStream inputStream = clazz.getResourceAsStream("/hello.txt");
        int res;
        byte[] bys = new byte[1024];
        while ((res = inputStream.read(bys)) != -1) {
            System.out.println(new String(bys, 0, res));
        }
    }
}                










