Android Studio Java 找不到文件异常
Android Studio Java File Not Found Exception
我尝试了我能想到的所有可能的路径组合以及文件的每个可能位置。它只是不会停止寻找文件未找到异常(没有文件或目录)
try {
String path = "D:\Users\[UserName]\Desktop\[NameofProject]\app\src\main\assets\itemsURL";
FileReader fileP = new FileReader(path);
BufferedReader reader= new BufferedReader(fileP);
for(String line; (line = reader.readLine()) != null; ) {
filesArray.add(line);
}
} catch (FileNotFoundException e){
e.printStackTrace();
有没有人遇到过这个问题,可能是最顽固的文件未找到异常?
java.io.FileNotFoundException: D:\Users\UserName]\Desktop\[NameofProject]\app\src\main\assets\itemsURL (No such file or directory)
文件格式是这样的:
algae_banana
boop_boop
word_word_word
bla_bla
...
事情不是这样的。您 运行 模拟器上的应用程序在 android 设备上没有路径 D:/users/...。
尝试使用 Assets 文件夹和 getAssetManager()
我尝试了我能想到的所有可能的路径组合以及文件的每个可能位置。它只是不会停止寻找文件未找到异常(没有文件或目录)
try {
String path = "D:\Users\[UserName]\Desktop\[NameofProject]\app\src\main\assets\itemsURL";
FileReader fileP = new FileReader(path);
BufferedReader reader= new BufferedReader(fileP);
for(String line; (line = reader.readLine()) != null; ) {
filesArray.add(line);
}
} catch (FileNotFoundException e){
e.printStackTrace();
有没有人遇到过这个问题,可能是最顽固的文件未找到异常?
java.io.FileNotFoundException: D:\Users\UserName]\Desktop\[NameofProject]\app\src\main\assets\itemsURL (No such file or directory)
文件格式是这样的:
algae_banana
boop_boop
word_word_word
bla_bla
...
事情不是这样的。您 运行 模拟器上的应用程序在 android 设备上没有路径 D:/users/...。
尝试使用 Assets 文件夹和 getAssetManager()