String path = System.getProperty("user.dir"); File file = new File(path,"data.txt"); 上面两行代码即可读取jar包同级目录中的data.txt文本文件。