net.wimpi.modbus.io
Class BytesOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by net.wimpi.modbus.io.FastByteArrayOutputStream
          extended by net.wimpi.modbus.io.BytesOutputStream
All Implemented Interfaces:
Closeable, DataOutput, Flushable

public class BytesOutputStream
extends FastByteArrayOutputStream
implements DataOutput

Class implementing a byte array output stream with a DataInput interface.

Version:
@version@ (@date@)
Author:
Dieter Wimberger

Field Summary
 
Fields inherited from class net.wimpi.modbus.io.FastByteArrayOutputStream
DEFAULT_SIZE
 
Constructor Summary
BytesOutputStream(byte[] buffer)
          Constructs a new BytesOutputStream instance with a given output buffer.
BytesOutputStream(int size)
          Constructs a new BytesOutputStream instance with a new output buffer of the given size.
 
Method Summary
 byte[] getBuffer()
          Returns the reference to the output buffer.
 void reset()
          Resets the count of this FastByteArrayOutputStream to zero, so that all currently accumulated output in the ouput stream is discarded when overwritten.
 void writeBoolean(boolean v)
           
 void writeByte(int v)
           
 void writeBytes(String s)
           
 void writeChar(int v)
           
 void writeChars(String s)
           
 void writeDouble(double v)
           
 void writeFloat(float v)
           
 void writeInt(int v)
           
 void writeLong(long v)
           
 void writeShort(int v)
           
 void writeUTF(String str)
           
 
Methods inherited from class net.wimpi.modbus.io.FastByteArrayOutputStream
close, ensureCapacity, size, toByteArray, toByteArray, toString, toString, write, write, write, writeTo
 
Methods inherited from class java.io.OutputStream
flush
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.io.DataOutput
write, write, write
 

Constructor Detail

BytesOutputStream

public BytesOutputStream(int size)
Constructs a new BytesOutputStream instance with a new output buffer of the given size.

Parameters:
size - the size of the output buffer as int.

BytesOutputStream

public BytesOutputStream(byte[] buffer)
Constructs a new BytesOutputStream instance with a given output buffer.

Parameters:
buffer - the output buffer as byte[].
Method Detail

getBuffer

public byte[] getBuffer()
Returns the reference to the output buffer.

Overrides:
getBuffer in class FastByteArrayOutputStream
Returns:
the reference to the byte[] output buffer.

reset

public void reset()
Description copied from class: FastByteArrayOutputStream
Resets the count of this FastByteArrayOutputStream to zero, so that all currently accumulated output in the ouput stream is discarded when overwritten.

Overrides:
reset in class FastByteArrayOutputStream

writeBoolean

public void writeBoolean(boolean v)
                  throws IOException
Specified by:
writeBoolean in interface DataOutput
Throws:
IOException

writeByte

public void writeByte(int v)
               throws IOException
Specified by:
writeByte in interface DataOutput
Throws:
IOException

writeShort

public void writeShort(int v)
                throws IOException
Specified by:
writeShort in interface DataOutput
Throws:
IOException

writeChar

public void writeChar(int v)
               throws IOException
Specified by:
writeChar in interface DataOutput
Throws:
IOException

writeInt

public void writeInt(int v)
              throws IOException
Specified by:
writeInt in interface DataOutput
Throws:
IOException

writeLong

public void writeLong(long v)
               throws IOException
Specified by:
writeLong in interface DataOutput
Throws:
IOException

writeFloat

public void writeFloat(float v)
                throws IOException
Specified by:
writeFloat in interface DataOutput
Throws:
IOException

writeDouble

public void writeDouble(double v)
                 throws IOException
Specified by:
writeDouble in interface DataOutput
Throws:
IOException

writeBytes

public void writeBytes(String s)
                throws IOException
Specified by:
writeBytes in interface DataOutput
Throws:
IOException

writeChars

public void writeChars(String s)
                throws IOException
Specified by:
writeChars in interface DataOutput
Throws:
IOException

writeUTF

public void writeUTF(String str)
              throws IOException
Specified by:
writeUTF in interface DataOutput
Throws:
IOException


Copyright © 2010. All Rights Reserved.