compression - Reading and Writing Bits to Text Files in Java -


i'm trying implement compression algorithms, , need deal bits in java.

what need when write value 1 value 2, numbers stored in file bits, file size 1 byte instead of 2, 1 stored in 1 bit , 2 stored in 2 bits.

is possible? much

all i/o methods have byte lowest granularity. can write bits, have pack them bytes yourself. maybe one-byte buffer write out file once fills appropriate.

also note there no way know length of file in bits (you not know if last byte "full"). application needs take care of somehow.

you can google "bitoutputstream", of there few, though not in libraries common. maybe use 1 of those.

finally, file creating not "text" file, binary (even more usual...)


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -