Java bits shifting within a .bin Binary File

February 17, 2012 at 01:46:33
Specs: Windows 7
I have a list of data which can be Integers, Floats, string or even chars etc that needs to be written into a .bin Binary file in binary format. Besides being able to write into the bin file, I need to be able to read from it too. However I need to be able to read and write from the bin file content non sequentially. An example of the file content is as below (the text below the bits are what it represent after retrieval):

011001 011000 00111001 101110001
Her name is Mary

Suppose I want to retrieve the name of the person. Instead of traversing from "Her" -> "name" -> "is" -> "Mary" to get my result, I need to be able to jump straight and get the binary representation of Mary and return the results.

Has anyone done something similar and is able to provide me with some insight to get a head start.

See More: Java bits shifting within a .bin Binary File

Report •

February 18, 2012 at 12:45:39
Mary starts 13 characters in. If you use a random access file you can access any character if you know its position. You can't replace Mary with Susan unless you had previously allow for a larger field and left empty space. A true binary file would usually need a fixed number of bits per character (usually 8).
I think you need to study data structures.

Report •
Related Solutions

Ask Question