Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1096729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:19:26+00:00 2026-05-17T00:19:26+00:00

does J2ME have something similar to RandomAccessFile class, or is there any way to

  • 0

does J2ME have something similar to RandomAccessFile class, or is there any way to emulate this particular (random access) functionality?

The problem is this: I have a rather large binary data file (~600 KB) and would like to create a mobile application for using that data. Format of that data is home-made and contains many index blocks and data blocks. Reading the data on other platforms (like PHP or C) usually goes like this:

  1. Read 2 bytes for index key (K), another 2 for index value (V) for the data type needed
  2. Skip V bytes from the start of the file to seek to a file position there the data for index key K starts
  3. Read the data
  4. Profit 🙂

This happens many times during the program flow.

Um, and I’m investigating possibility of doing the very same on J2ME, and while I admit I’m quite new to the whole Java thing, I can’t seem to be able to find anything beyond InputStream (DataInputStream) classes which don’t have the basic seeking/skipping to byte/returning position functions I need.

So, what are my chances?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T00:19:27+00:00Added an answer on May 17, 2026 at 12:19 am

    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 the marke/reset methods, I think it is better to save the offset from the val location not from the start of the file so you can skip these methods. I think they have som issues on some devices.

    One more note, I don’t recommend to open a 600 KB file, it will crash the application on many low end devices, you should split this file to multiple files.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does any one know how I can have this happen in a windows phone
I'm dealing with a midlet in j2me, and I have this thread class (say
Does anyone know if this is possible in J2ME; I want to have an
Does every j2me enabled mobile have GPS service so that the developer can locate
i have a j2me application , it does the File IO operation, but every
i have an Java J2ME application that does (at user request) create HttpConnections to
Sorry, this is along one to document.. OLD SETUP I have a J2ME client
I am working on a BlackBerry j2me Java implementation that does not have the
Does anyone know is there a better way to check if some image contain
I cannot find much documentation about HashMaps in j2me. Does anyone have experience with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.