public class BinaryOutputStream
extends java.io.FilterOutputStream
| Modifier and Type | Field and Description |
|---|---|
static int |
BYTE_CHAR |
static int |
LITTLE_ENDIAN |
| Constructor and Description |
|---|
BinaryOutputStream(java.io.OutputStream out)
Creates a new BinaryOutputStream from an output stream.
|
BinaryOutputStream(java.io.OutputStream out,
int flags)
Creates a new BinaryOutputStream from an output stream and prescribed set
of flag values.
|
| Modifier and Type | Method and Description |
|---|---|
int |
getFlags()
Gets the flags for this stream.
|
boolean |
isLittleEndian()
Returns
true if this stream converts it's output to
little-endian where appropriate. |
void |
setByteChar(boolean bytechar)
Sets whether or not this stream uses byte-length characters as opposed to
2-byte word characters.
|
void |
setFlags(int flags)
Sets the flags for this stream.
|
void |
setLittleEndian(boolean little)
Sets whether or not this stream converts its output to little-endian.
|
int |
size()
Returns the number of bytes that have been written to this stream.
|
boolean |
usesByteChar()
Returns
true if this stream uses byte-length characters as
opposed to 2-byte word characters. |
void |
write(byte[] data,
int off,
int len)
Writes
len byte values from datato this stream,
starting at off. |
void |
write(int b)
Writes a single byte value to this stream.
|
void |
writeBoolean(boolean b)
Writes a boolean value to this stream.
|
void |
writeByte(int b)
Writes a byte value to this stream.
|
void |
writeBytes(java.lang.String s)
Writes the bytes of a string to this stream.
|
void |
writeChar(int c)
Writes a character value to this stream.
|
void |
writeChars(java.lang.String s)
Writes the characters of a string to this stream.
|
void |
writeDouble(double d)
Writes a double value to this stream.
|
void |
writeFloat(float f)
Writes a float value to this stream.
|
void |
writeInt(int v)
Writes an integer value to this stream.
|
void |
writeLong(long v)
Writes a long value to this stream.
|
void |
writeShort(int s)
Writes a short value to this stream.
|
void |
writeUTF(java.lang.String s)
Writes a UTF-8 string to this stream.
|
public static final int LITTLE_ENDIAN
public static final int BYTE_CHAR
public BinaryOutputStream(java.io.OutputStream out)
out - underlying output streampublic BinaryOutputStream(java.io.OutputStream out,
int flags)
out - underlying output streamflags - flag valuespublic void setFlags(int flags)
flags - new flag valuespublic int getFlags()
public boolean isLittleEndian()
true if this stream converts it's output to
little-endian where appropriate.true if this stream converts to little-endianpublic void setLittleEndian(boolean little)
little - if true, enables little-endian conversion.public boolean usesByteChar()
true if this stream uses byte-length characters as
opposed to 2-byte word characters.true if this stream uses byte-length characterspublic void setByteChar(boolean bytechar)
bytechar - if true, enables byte-length characters.public final void write(int b)
throws java.io.IOException
write in class java.io.FilterOutputStreamb - byte value to writejava.io.IOExceptionpublic final void write(byte[] data,
int off,
int len)
throws java.io.IOException
len byte values from datato this stream,
starting at off.write in class java.io.FilterOutputStreamdata - byte values to writeoff - starting point within datalen - number of bytes to writejava.io.IOExceptionpublic final void writeBoolean(boolean b)
throws java.io.IOException
b - boolean value to writejava.io.IOExceptionpublic final void writeByte(int b)
throws java.io.IOException
b - byte value to writejava.io.IOExceptionpublic final void writeShort(int s)
throws java.io.IOException
isLittleEndian() returns
true, then the byte order is switched from
big-endian to little-endian.s - short value to writejava.io.IOExceptionpublic final void writeChar(int c)
throws java.io.IOException
usesByteChar() returns
true or false. In the latter case, if isLittleEndian() returns true, then the byte order is switched
from big-endian to little-endian.c - character value to writejava.io.IOExceptionpublic final void writeInt(int v)
throws java.io.IOException
isLittleEndian() returns
true, then the byte order is switched from
big-endian to little-endian.v - integer value to writejava.io.IOExceptionpublic final void writeLong(long v)
throws java.io.IOException
isLittleEndian() returns
true, then the byte order is switched from
big-endian to little-endian.v - long value to writejava.io.IOExceptionpublic void writeBytes(java.lang.String s)
throws java.io.IOException
s - string to writejava.io.IOExceptionpublic void writeChars(java.lang.String s)
throws java.io.IOException
usesByteChar() returns
true or false. In the latter case, if isLittleEndian() returns true, then the byte order is switched
from big-endian to little-endian.java.io.IOExceptionpublic final void writeFloat(float f)
throws java.io.IOException
isLittleEndian() returns
true, then the byte order is switched from
big-endian to little-endian.f - float value to writejava.io.IOExceptionpublic final void writeDouble(double d)
throws java.io.IOException
isLittleEndian() returns
true, then the byte order is switched from
big-endian to little-endian.d - double value to writejava.io.IOExceptionpublic final void writeUTF(java.lang.String s)
throws java.io.IOException
s - string to writejava.io.IOExceptionpublic int size()