找不到Android Studio Java文件异常 [英] Android Studio Java File Not Found Exception

查看:302
本文介绍了找不到Android Studio Java文件异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试了所有可能想到的路径组合以及文件的每个可能位置.它根本不会停止文件未找到"异常(没有文件或目录)

I tried every possible combination of paths that i could think of along with every possible location of the file. It simply does not stop going for the file Not Found exception (No file or Directory)

  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();

是否有人遇到过最顽固的文件未找到"异常的问题?

Has anyone ever got this problem of, possibly, the most stubborn File Not Found exception?

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/....

That's not how it works. You run the app on an emulator and there is no path D:/users/... on an android Device.

尝试使用他的Assets文件夹和getAssetManager()

Try using he Assets folder and the getAssetManager()

这篇关于找不到Android Studio Java文件异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆