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 7530483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:55:23+00:00 2026-05-30T04:55:23+00:00

I have a bunch of different objects(and objec types) that i want to write

  • 0

I have a bunch of different objects(and objec types) that i want to write to a binary file. First of all i need the file to be structured like this:

`Object type1

obj1, obj2 ...

Object type2

obj1, obj2...

….

Being a binary file this doesn’t help a user read it, but i want to have a structure so i can search, delete or add an object by it’s type, not parsing the entire file. And this is something i don’t know how to do. Is this even posible?

  • 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-30T04:55:25+00:00Added an answer on May 30, 2026 at 4:55 am

    You will have to maintain a header at the beginning of the file (or somewhere else) to mark the position and length of each of your objects.

    The kind and layout of the header depend a lot on how you plan to read and write into the file. For example if you plan to retrieve the objects by name, you could have in your file something like this

    object1 500 1050
    object2 1550 800
    object3 2350 2000
    <some padding to cover 500 bytes>
    <the 1050 bytes of object1><the 800 bytes of object2><the 2000 bytes of object3> 
    

    And know that object1 starts at the offset 400 in the file, and has a length of 1050 bytes.

    Since it seems that you have different types of objects that you want to store, you will probably need to add some additional data to your header.

    Take care of the following:

    • Each time you add, delete or modifiy a file, you will have to update in the header the offset for all files that follow (for example if I remove object2, then the offset for object3 is now 1550).
    • If you store the header in the same file as the data, then you must take the size of the header into account when computing offsets (this will make things much harder, I suggest you keep the header and binary data separated.
    • You will have to read and parse the header each time you want to access an object. Consider using a standardized format for your header to avoid problems (YML or XML).

    I’m not aware of any library that will help you implement such a feature but I’m pretty sure there are some. Maybe someone will be able to suggest one.

    —

    Another solution would be to use something like a ZipFile (which is natively supported by Java) and write each of your objects as a differenz ZipEntry. This way you won’t have to manage object separation yourself, and will only need to worry about knowing the exact ZipEntry you want.

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

Sidebar

Related Questions

I have a bunch of different objects that are commonly edited in the same
I have a bunch of objects at different coordinates, and I need to animate
Let's say that I have a bunch of class instances that serve different purposes,
I have a bunch of files that I need to be able to transport
Like many 3d graphical programs, I have a bunch of objects that have their
I have a bunch of datetime objects and I want to calculate the number
I have a bunch of code of the form: someVector.push_back(Foo(some name, 1.0, 3.1415926); someVector.push_back(Foo(different
I have a bunch of latitude/longitude pairs that map to known x/y coordinates on
I have a bunch of .NET frameworks installed on my machine. I know that
I have a bunch of classes I want to rename. Some of them have

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.