org.cip4.jdflib.util
Class ByteArrayIOStream

java.lang.Object
  extended by java.io.OutputStream
      extended by java.io.ByteArrayOutputStream
          extended by org.cip4.jdflib.util.ByteArrayIOStream
All Implemented Interfaces:
Closeable, Flushable

public class ByteArrayIOStream
extends ByteArrayOutputStream

Shared input / outputStream class write once, read many...

Author:
rainer prosi

Nested Class Summary
static class ByteArrayIOStream.ByteArrayIOInputStream
          bytearrayinputstream that allows duplication without copying
 
Field Summary
 
Fields inherited from class java.io.ByteArrayOutputStream
buf, count
 
Constructor Summary
ByteArrayIOStream()
          creates an empty input output stream class
ByteArrayIOStream(byte[] b)
          creates a sized input output stream class
ByteArrayIOStream(File f)
          create a ByteArrayIOStream from a file
ByteArrayIOStream(InputStream is)
          creates an input output stream class from any stream if is alraedy is a buffered inputstream, no copy is made
ByteArrayIOStream(int i)
          creates a sized input output stream class
 
Method Summary
 byte[] getBuf()
          get the internal buffer - be careful, this is THE buffer
static ByteArrayIOStream.ByteArrayIOInputStream getBufferedInputStream(InputStream is)
          get a completely buffered and resizable input stream
 ByteArrayIOStream.ByteArrayIOInputStream getInputStream()
          gets an input stream based on the current byte contents - note this operates on the internal data
 String toString()
           
 
Methods inherited from class java.io.ByteArrayOutputStream
close, reset, size, toByteArray, toString, toString, write, write, writeTo
 
Methods inherited from class java.io.OutputStream
flush, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ByteArrayIOStream

public ByteArrayIOStream()
creates an empty input output stream class


ByteArrayIOStream

public ByteArrayIOStream(int i)
creates a sized input output stream class

Parameters:
i - the size of the stream

ByteArrayIOStream

public ByteArrayIOStream(InputStream is)
creates an input output stream class from any stream if is alraedy is a buffered inputstream, no copy is made

Parameters:
is - the inputstream to buffer

ByteArrayIOStream

public ByteArrayIOStream(File f)
                  throws IOException
create a ByteArrayIOStream from a file

Parameters:
f - the file
Throws:
IOException

ByteArrayIOStream

public ByteArrayIOStream(byte[] b)
creates a sized input output stream class

Parameters:
b - the buffer to use (is NOT copied)
Method Detail

getBufferedInputStream

public static ByteArrayIOStream.ByteArrayIOInputStream getBufferedInputStream(InputStream is)
get a completely buffered and resizable input stream

Parameters:
is -
Returns:

getInputStream

public ByteArrayIOStream.ByteArrayIOInputStream getInputStream()
gets an input stream based on the current byte contents - note this operates on the internal data

Returns:
an input stream

getBuf

public byte[] getBuf()
get the internal buffer - be careful, this is THE buffer

Returns:
the internal buffer

toString

public String toString()
Overrides:
toString in class ByteArrayOutputStream
See Also:
ByteArrayOutputStream.toString()


Copyright © 2013. All Rights Reserved.