读取包内文件,使用的路径一定是相对的classpath路径,比如a,位于包内,此时可以创建读取a的字节流:InputStream in = ReadFile.class.getResourceAsStream("/com/lavasoft/res/a.txt");有了字节流,就能读取到文件内容了。