java me - File random access in J2ME -


Is there something similar to the square of J2ME, or is there any way to emulate the functionality of this particular (random access) The way?

The problem is: I have a large binary data file (~ 600 KB) and want to create a mobile application to use that data. The format of that data is made home and has several index blocks and data blocks. Reading data on other platforms (such as PHP or C) usually happens like this:

  1. Read 2 bytes for the index key ( of ), the value of the index For the second 2 data type, V )
  2. Skip the V bytes from the beginning of the file, find the status of the data for the index of the data there <
  3. Profitable:

This program occurs several times during the flow.

  • P>

    Um, and I'm checking the possibility of doing a lot on J2ME, and when I believe that I am quite new to the whole Java thing, I can not even get () the sections which do not have the basic requirement / byte / returning function functions are required. I \ n

    So, what are my chances?

  • you should have something like

      try {DataInputStream di = New DataInputStream (is); Di.marke (9999); Small key = di.readShort (); Small val = di.readShort (); Di.reset (); Di.skip (val); Byte [] B = new byte [255]; Di.read (b); } Hold (Exception pre) {ex.printStackTrace (); }  

    I do not like to use the mark / reset methods, I think the offset is not left from the beginning of the file to save it from the right place, so that you can use these methods Leave it. I think they have some problems on some devices.

    Another note, I do not recommend opening a 600 KB file, it will crash the application on many low end devices, you will need to download this file to multiple files.


    Comments