I am new to java, and to be honest, programming. And I was looking at the archive on bitinputstream and bitoutputstreams, and I was wondering if the available source code that is available on this link: http://archive.devx.com/java/free/ar...52002_code.zip
is a non-standard class like textio where I can import it into a program where I will implement its features. Such as reading and writing single bits without having to worry about resetting the buffer like it shows on :http://archive.devx.com/java/free/ar...gt052002-1.asp.
I understand how the buffer works; it is just that I don't want to worry about figuring out how to write it into code. I have no problem with the fact of just reading bits and writing bits as it is shown on the previous link, or is it more complicated than that. You're input would be much appreciated, thank you.

10-13-2005, 09:35 PM

Norm

Not sure that you can read/write less than 8 bits (byte) at a time.
As a new comer, why not study Sun's classes first?

What is your question?

10-13-2005, 10:24 PM

nspils

Pretty advanced stuff for someone who is not only new to Java but also new to programming.

Why are you wanting to address individual bits?

I follow the discussion in the articles you referenced, but I can't think of a way to accomplish the tasks they discuss without re-creating what the authors have already implemented. You cannot read bits at a time from a stream - the smallest you can read is a byte which can then be converted to bits as the authors discuss. Can store in a BitSet. Once the input is converted to a BitSet you can address a particular bit ...

10-15-2005, 01:14 AM

kingkong sr.

the article states that you can manipulate individual bits within a buffer that is a byte in length, and when you are finished, the buffer is flushed and is written as a byte to file. The classes allow you to read and write individual bits, but lets say you reach the end of your manipulation. And there's only three bits that you manipulated within the buffer; when the buffer is flushed, five padding bits are added to the file (which are five 0's). I believe the article states that the classes don't allow you to write a bit at a time but allow you to manipulate a file so that it is like doing so. but you would have to keep up with the padding bits at the end of your manipulation. On the link that i gave, it stated that you could read bits sequentially such as, int b0 = bin.readBit(); for the first bit. I was wondering if i could do a b++ sort of thing where everytime i write b = bin.readbit(), in the code it would allow me to read the bits sequentially all the way up to the end of the file. where I would write:
for (b = bin.readbit())
if b = 1
blah blah blah
elseif
blah blah blah
for (b = bin.readbit())
if b = 1
blah blah blah
elseif
blah blah blah
where the next (b = bin.readbit()) is the next bit being read and blah blah blah is any code i write for that condition. I suppose before i write that code I would make for (b = 0, b < eof, b++) under which the rest of the could is written.

10-15-2005, 11:24 AM

nspils

Have you looked at the BitSet class?

10-15-2005, 01:47 PM

kingkong sr.

i have looked at it in c++ but i had difficulty with it. I suppose i will look at it again for java. thanks for your suggestion.