pui*_*ant 1 java directory fileinputstream bufferedreader
我有一个初始化文件(initialize.java),它使用fileInputStream从fileInput.txt中提取数据,但它们都位于不同的目录中.
Run Code Online (Sandbox Code Playgroud)Project/library/initialize.java Project/resources/text/fileInput.txt
我在initialize.java中的代码是:
FileInputStream fstream = new FileInputStream("/resources/text/fileInput.txt");
Run Code Online (Sandbox Code Playgroud)
但是文件无法读取.我也试过了
FileInputStream fstream = new FileInputStream("./resources/text/fileInput.txt");
Run Code Online (Sandbox Code Playgroud)
但那也行不通.
如何访问txt文件以及使用"./resources"和"/ resources"之间的区别是什么?
感谢您阅读本文.