Writing single bits to a file

R

riva

Normally we write to files in the form of characters.
Is there any way so that we can write data to the file in the form
single bits like five `0's and then six `1's etc.
 
K

Knute Johnson

riva said:
Normally we write to files in the form of characters.
Is there any way so that we can write data to the file in the form
single bits like five `0's and then six `1's etc.

Yes but you will have to write them in groups of 8. But why would you
want to do this? Do you need to write trillions of bits? Why not just
use some simple scheme to represent them for example characters 0 and 1
or byte values 0 and 1? Java has a really neat class called BitSet.
You could store one of those if you wanted.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top