You should have something like this
try { DataInputStream di = new DataInputStream(is); di.marke(9999); short key = di.readShort(); short val = di.readShort(); di.reset(); di.skip(val); byte[] b= new byte[255]; di.read(b); }catch(Exception ex ) { ex.printStackTrace(); }
I prefer not to use marke / reset methods, I think itβs better to keep the offset from the val location not from the beginning of the file so you can skip these methods. I think they have some problems on some devices.
One more note: I do not recommend opening a file with a size of 600 KB, this will lead to a crash of the application on many devices with low access level, you should split this file into several files.
source share