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?
How about this:
InputStream in = context.getAssets().open("openAccess.txt");
reader = new InputStreamReader(in);
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);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With