Class wb.BytePackOutputStream
All Packages Class Hierarchy This Package Previous Next Index
Class wb.BytePackOutputStream
java.lang.Object
|
+----wb.BytePackOutputStream
- public class BytePackOutputStream
- extends Object
This class lets you write primitive Java data types
to a byte array in a portable way. Primitive data types are well
understood types with associated operations. For example, an
Integer is considered to be a good primitive data type.
The data can be converted back using a ByteUnPackInputStream.
-
buf
- The buffer where data is stored.
-
count
- The number of bytes in the buffer.
-
outstream
- The real stream onto which the byte array will be written
-
BytePackOutputStream(OutputStream)
- Creates a new BytePackOutputStream.
-
size()
- Returns the current size of the local buffer which would be written
when sync'd
-
sync()
- Writes a byte buffer to the stream that was specified
during instantiation.
-
sync(OutputStream)
- Writes a byte buffer to the specified stream.
-
writeBoolean(boolean)
- Writes a boolean.
-
writeByte(int)
- Writes an 8 bit byte.
-
writeBytes(String)
- Writes a String as a sequence of bytes.
-
writeChar(int)
- Writes a 16 bit char.
-
writeChars(String)
- Writes a String as a sequence of chars.
-
writeDouble(double)
- Writes a 64 bit double.
-
writeFloat(float)
- Writes a 32 bit float.
-
writeInt(int)
- Writes a 32 bit int.
-
writeLong(long)
- Writes a 64 bit long.
-
writeShort(int)
- Writes a 16 bit short.
buf
protected byte buf[]
- The buffer where data is stored.
count
protected int count
- The number of bytes in the buffer.
outstream
protected OutputStream outstream
- The real stream onto which the byte array will be written
BytePackOutputStream
public BytePackOutputStream(OutputStream out)
- Creates a new BytePackOutputStream.
- Parameters:
- out - the output stream
sync
public synchronized void sync() throws IOException
- Writes a byte buffer to the stream that was specified
during instantiation.
sync
public synchronized void sync(OutputStream out) throws IOException
- Writes a byte buffer to the specified stream.
- Parameters:
- out - OutputStream to which the byte array is written.
the internal buffer is uneffected.
writeBoolean
public synchronized void writeBoolean(boolean v)
- Writes a boolean.
- Parameters:
- v - the boolean to be written
writeByte
public synchronized void writeByte(int v)
- Writes an 8 bit byte.
- Parameters:
- v - the byte value to be written
writeShort
public synchronized void writeShort(int v)
- Writes a 16 bit short.
- Parameters:
- v - the short value to be written
writeChar
public synchronized void writeChar(int v)
- Writes a 16 bit char.
- Parameters:
- v - the char value to be written
writeInt
public synchronized void writeInt(int v)
- Writes a 32 bit int.
- Parameters:
- v - the integer value to be written
writeLong
public synchronized void writeLong(long v)
- Writes a 64 bit long.
- Parameters:
- v - the long value to be written
writeFloat
public synchronized void writeFloat(float v)
- Writes a 32 bit float.
- Parameters:
- v - the float value to be written
writeDouble
public synchronized void writeDouble(double v)
- Writes a 64 bit double.
- Parameters:
- v - the double value to be written
writeBytes
public synchronized void writeBytes(String s)
- Writes a String as a sequence of bytes.
- Parameters:
- s - the String of bytes to be written
writeChars
public synchronized void writeChars(String s)
- Writes a String as a sequence of chars.
- Parameters:
- s - the String of chars to be written
size
public int size()
- Returns the current size of the local buffer which would be written
when sync'd
All Packages Class Hierarchy This Package Previous Next Index