views:

46

answers:

1

Hello,

can anyone tell me how to random access a file beyond 2GB with android SDK. I was trying to seek to a position > 2147483647 and got the exception: "Value too large for defined datatype". That is odd as the parameter for the seek command is type "long". See the code example for details:

RandomAccessFile    BigFile;
BigFile = new RandomAccessFile(sMyFileName, "r");
BigFile.seek(2147483648);
   --> Exception

Thanks for any help, Michael

+2  A: 

That is the result of the exception bubbling up from the native/IO (system) layer. It doesn't have to do with the size of the type in the language/VM itself. The error at the lower lever is EOVERFLOW ("Value to large for defined data type"). lseek, for instance, lists this error.

Hypothesis: The underlying system access isn't 64-bit "aware" :-) Some real JREs also had this problem historically, IIRC. Not sure what the story on android is.

Edit: The thread at FAT32 file size limited to 2GB seems to relate the Android 2.x (and contains details/hints/hypothesis about the kernel build and/or IO lib limitations -- consensus is "it doesn't work").

pst
Thanks for the answer. Actually i read this article while i was searching for a solution. But my hope was that they are all wrong and there IS a solution. :-/ But i think you are right. THe underlaying IO system seems not to use 64bit. (But lseek64 is actually part of the Android OS - why is it not used ?)
Michael