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

  • Home
  • SEARCH
  • 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 5839883
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T11:39:20+00:00 2026-05-22T11:39:20+00:00

basically I have a file of String Objects. I used Java ObjectOutputStream to store

  • 0

basically I have a file of String Objects. I used Java ObjectOutputStream to store the objects. Is it possible to access the objects(Strings) randomly, say if I want to access the 11th object, I could just somehow jump to that location without having to use readObject() 11th times to loop to that location. And if I wanna to jump back, I could do it also, without having to loop from the start again. Thanks.

As it is suggested, I think I can somehow do use skipBytes() method to realize some sort of random access. Although I can’t guarantee that my object is of fixed size, but what if I can keep an array of positions of those objects in the file, I could just use that array as an index and skipBytes() to random access. So the problem remains, anyway that I could know the size of objects when I am actually writing them, so that I could record the position somehow?

  • 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-22T11:39:20+00:00Added an answer on May 22, 2026 at 11:39 am

    The ObjectOutputStream itself cannot do that, because first of all it cannot know the size of the objects in that file; actually, it cannot even know that the objects are of the same type.

    If you know for sure that the objects are fixed-sized and you know that size, you can make use of the skipBytes() method — but I strongly doubt you really know that.


    EDIT:
    Thanks for accepting my answer, but (just make things clear): my intention was to show one way this could be done given the requirements that you mentioned, but this is not at all the way it should be done, in my opinion. 🙂

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

Sidebar

Related Questions

Imagine a sequence of java.io.File objects. The sequence is not in any particular order,
I have an ItemsControl bound to a list of objects. It basically displays a
So I have this code right, and it basically reads an XML file and
I have a flash file which is basically an animated TV that flicks through
I basically have a page which shows a processing screen which has been flushed
I basically have the following flow: XML -> JSON -> Spring MVC -> jsp
I am looking in to ways to enable a site to basically have something
I would like to do the following. Basically have a stored procedure call another
Basically I have some code to check a specific directory to see if an
Basically I have a bunch of unmanaged VC++ static libraries. And the VC++ GUI

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.