Package org.cip4.jdflib.util
Class ByteArrayIOStream
- java.lang.Object
-
- java.io.OutputStream
-
- java.io.ByteArrayOutputStream
-
- org.cip4.jdflib.util.ByteArrayIOStream
-
- All Implemented Interfaces:
java.io.Closeable,java.io.Flushable,java.lang.AutoCloseable
- Direct Known Subclasses:
ByteArrayIOFileStream
public class ByteArrayIOStream extends java.io.ByteArrayOutputStreamShared input / outputStream class write once, read many...
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classByteArrayIOStream.ByteArrayIOInputStreambytearrayinputstream that allows duplication without copying
-
Constructor Summary
Constructors Constructor Description ByteArrayIOStream()creates an empty input output stream classByteArrayIOStream(byte[] b)creates a sized input output stream classByteArrayIOStream(int i)creates a sized input output stream classByteArrayIOStream(java.io.File f)create a ByteArrayIOStream from a fileByteArrayIOStream(java.io.InputStream is)creates an input output stream class from any stream if is alraedy is a buffered inputstream, no copy is made
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()byte[]getBuf()get the internal buffer - be careful, this is THE bufferstatic ByteArrayIOStream.ByteArrayIOInputStreamgetBufferedInputStream(java.io.InputStream is)get a completely buffered and resizable input streamByteArrayIOStream.ByteArrayIOInputStreamgetInputStream()gets an input stream based on the current byte contents and positions - note this operates on the internal dataByteArrayIOStream.ByteArrayIOInputStreamgetNewStream()gets an input stream starting at 0 based on the current byte contents - note this operates on the internal datajava.lang.StringtoString()
-
-
-
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(java.io.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(java.io.File f) throws java.io.IOExceptioncreate a ByteArrayIOStream from a file- Parameters:
f- the file- Throws:
java.io.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(java.io.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 and positions - note this operates on the internal data- Returns:
- an input stream
-
getNewStream
public ByteArrayIOStream.ByteArrayIOInputStream getNewStream()
gets an input stream starting at 0 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 java.lang.String toString()
- Overrides:
toStringin classjava.io.ByteArrayOutputStream- See Also:
ByteArrayOutputStream.toString()
-
close
public void close()
- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.ByteArrayOutputStream- See Also:
ByteArrayOutputStream.close()
-
-