Android: getAssets().openFd() and FileNotFoundException

android, android-assets

Solution

try this :

AssetFileDescriptor descriptor = getAssets().openFd("openAccess.txt");
BufferedReader f = new BufferedReader(new FileReader(descriptor.getFileDescriptor()));
String line = f.readLine();
while (line != null) {
    // do stuff
    Log.d("TAG",line);
}

Problem

I am trying to read a txt file from assets folder like that: ``` descriptor = context.getAssets().openFd("openAccess.txt"); reader = new FileReader(descriptor.getFileDescriptor()); ``` but I am getting this exception: java.io.FileNotFoundException: This file can not be opened as a file descriptor; it is probably compressed I don't know what is the problem?

Original source

Related problems