我正在尝试从 assets 文件夹中读取一个 txt 文件:
descriptor = context.getAssets().openFd("openAccess.txt");
reader = new FileReader(descriptor.getFileDescriptor());
但我遇到了这个异常:
java.io.FileNotFoundException: This file can not be opened as a file descriptor; it is probably compressed
不知道是什么问题?
最佳答案
这个怎么样:
InputStream in = context.getAssets().open("openAccess.txt");
reader = new InputStreamReader(in);
关于安卓:getAssets().openFd() 和 FileNotFoundException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10141251/