ggz.common.dio
Class DIOOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by java.io.FilterOutputStream
          extended by java.io.DataOutputStream
              extended by ggz.common.dio.DIOOutputStream
All Implemented Interfaces:
java.io.Closeable, java.io.DataOutput, java.io.Flushable
Direct Known Subclasses:
GGZCardOutputStream

public class DIOOutputStream
extends java.io.DataOutputStream

This class does not write anything to the output stream until the flush() method is called. All writes first go into an internal buffer so that the size of a packet can be determined. When the flush() method is called, a "packet header" is written that contains the size of the packet (including the header) in bytes.

Author:
Helg.Bredow

Field Summary
 
Fields inherited from class java.io.DataOutputStream
written
 
Fields inherited from class java.io.FilterOutputStream
out
 
Constructor Summary
DIOOutputStream(java.io.OutputStream os)
           
 
Method Summary
 void endPacket()
          Writes out the bytes that we have accumulated in previous write operations, preceded by a packet header that specifies the size of the packet.
 void writeString(java.lang.String message)
          Writes a char string to the given fd preceeded by its size.
 
Methods inherited from class java.io.DataOutputStream
flush, size, write, write, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeDouble, writeFloat, writeInt, writeLong, writeShort, writeUTF
 
Methods inherited from class java.io.FilterOutputStream
close, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.io.DataOutput
write
 

Constructor Detail

DIOOutputStream

public DIOOutputStream(java.io.OutputStream os)
Method Detail

writeString

public void writeString(java.lang.String message)
                 throws java.io.IOException
Writes a char string to the given fd preceeded by its size. The string is encoded using UTF-8.

Throws:
java.io.IOException

endPacket

public void endPacket()
               throws java.io.IOException
Writes out the bytes that we have accumulated in previous write operations, preceded by a packet header that specifies the size of the packet.

Throws:
java.io.IOException