views:

203

answers:

1

Trying to read a binary data file in the assets directory of android app:

void loadFile(InputStream filein){

  log(filein.available()); // returns 11310099

  int a = filein.read(); // returns -1 (i.e. EOF)
}

// Function was called using:
loadFile(context.getAssets().open("filename.dat"));

So if available() correctly returns that there is 11MB of data available in the filehandle, how can read() immediately return -1 as soon as I try to read the first byte?

A: 

OK, seems this is dupe of http://stackoverflow.com/questions/3034615/android-assets-no-value-read and android is quietly compressing the file in a way that fails at 1MB. Still, filein.available() should probably return 0 in this case?

OJW