it.geosolutions.io.output
Class BitOutputStream

Object
  extended by OutputStream
      extended by FilterOutputStream
          extended by BitOutputStream
All Implemented Interfaces:
Closeable, Flushable

public final class BitOutputStream
extends FilterOutputStream

Providing ability to write decorate outputstream with a bit oriented interface.

Author:
Simone Gianecchini

Field Summary
 
Fields inherited from class FilterOutputStream
out
 
Constructor Summary
BitOutputStream(OutputStream out)
           
 
Method Summary
 void flush()
          writes bits from buffer to output stream
 void write(boolean bit)
          Write a bit to this bit oriented stream.
 void write(byte[] b)
          Writes b.length bytes to this output stream.
 void write(byte[] b, int off, int len)
          Writes len bytes from the specified byte array starting at offset off to this output stream.
 void write(byte b, int nbits)
          Writes some bits (max 8) from the specified byte to stream.
 void write(int b)
          Writes the specified byte to this bit-wise output stream.
 void write(int bitVect, int length)
          Write an integer as a bit vector of the specified length.
 
Methods inherited from class FilterOutputStream
close
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BitOutputStream

public BitOutputStream(OutputStream out)
Method Detail

write

public void write(byte b,
                  int nbits)
           throws IOException
Writes some bits (max 8) from the specified byte to stream.

Parameters:
b - int which should be written
nbits - bit count to write
Throws:
IOException - if an I/O error occurs

flush

public void flush()
           throws IOException
writes bits from buffer to output stream

Specified by:
flush in interface Flushable
Overrides:
flush in class FilterOutputStream
Throws:
IOException - if I/O error occurs

write

public void write(boolean bit)
           throws IOException
Write a bit to this bit oriented stream.

Parameters:
bit - boolean
Throws:
IOException - DOCUMENT ME!

write

public void write(int bitVect,
                  int length)
           throws IOException
Write an integer as a bit vector of the specified length.

Parameters:
bitVect - int
length - DOCUMENT ME!
Throws:
IOException - DOCUMENT ME!

write

public void write(int b)
           throws IOException
Writes the specified byte to this bit-wise output stream.

The write method of BitOutputStream does nto always cals the write method of its underlying output stream.

Implements the abstract write method of OutputStream.

Overrides:
write in class FilterOutputStream
Parameters:
b - the byte.
Throws:
IOException - if an I/O error occurs.

write

public void write(byte[] b)
           throws IOException
Writes b.length bytes to this output stream.

The write method of FilterOutputStream calls its write method of one argument with the argument b.

Note that this method does not call the one-argument write method of its underlying stream with the single argument b.

Overrides:
write in class FilterOutputStream
Parameters:
b - the data to be written.
Throws:
IOException - if an I/O error occurs.
See Also:
FilterOutputStream.write(byte[], int, int)

write

public void write(byte[] b,
                  int off,
                  int len)
           throws IOException
Writes len bytes from the specified byte array starting at offset off to this output stream.

The write method of FilterOutputStream calls the write method of one argument on each byte to output.

Note that this method does not call the write method of its underlying input stream with the same arguments.

Overrides:
write in class FilterOutputStream
Parameters:
b - the data.
off - the start offset in the data.
len - the number of bytes to write.
Throws:
IOException - if an I/O error occurs.
See Also:
FilterOutputStream.write(int)


Copyright © 2006-2010 GeoSolutions. All Rights Reserved.