public class BitOutputStream extends OutputStream
| Constructor and Description |
|---|
BitOutputStream(OutputStream out)
Create a stream that writes-through to the
OutputStream object
passed as a parameter. |
BitOutputStream(String filename)
Construct a bit-at-a-time output stream with specified file
name.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Releases system resources associated with file and
flushes bits not yet written.
|
void |
flush()
Flushes bits not yet written, must be called by client
programs if
close isn't called. |
void |
write(int b)
Required by OutputStream subclasses, write the low
8-bits to the underlying outputstream
|
void |
writeBits(int howManyBits,
int value)
Write specified number of bits from value to a file.
|
write, writepublic BitOutputStream(OutputStream out)
OutputStream object
passed as a parameter.out - is the output stream to which bits are writtenpublic BitOutputStream(String filename)
filename - is the name of the file being writtenRuntimeException - if opening file fails for either FileNotFound
or for Security exceptoinspublic void write(int b)
throws IOException
write in class OutputStreamIOExceptionpublic void flush()
close isn't called.flush in interface Flushableflush in class OutputStreamRuntimeException - if there's a problem writing bitspublic void close()
close in interface Closeableclose in interface AutoCloseableclose in class OutputStreamRuntimeException - if close failspublic void writeBits(int howManyBits,
int value)
howManyBits - is number of bits to write (1-32)value - is source of bits, rightmost bits are writtenRuntimeException - if there's an I/O problem writing bits