Package org.cip4.jdflib.util
Class ByteArrayIOFileStream
java.lang.Object
java.io.OutputStream
java.io.ByteArrayOutputStream
org.cip4.jdflib.util.ByteArrayIOStream
org.cip4.jdflib.util.ByteArrayIOFileStream
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
Shared input / outputStream class write once, read many...
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassbytearrayinputstream that allows duplication without copyingNested classes/interfaces inherited from class org.cip4.jdflib.util.ByteArrayIOStream
ByteArrayIOStream.ByteArrayIOInputStream -
Field Summary
Fields inherited from class java.io.ByteArrayOutputStream
buf, count -
Constructor Summary
ConstructorsConstructorDescriptionByteArrayIOFileStream(long maxLength) creates an empty input output stream classByteArrayIOFileStream(File f, long maxLength, boolean readOnly) create a ByteArrayIOStream from a fileByteArrayIOFileStream(InputStream is, long maxLength) creates an input output stream class from any stream if is already is a buffered inputstream, no copy is made -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()protected voidfinalize()getBufferedInputStream(InputStream is, long maxLen) get a completely buffered and resizable input streamgetFile()gets an input stream based on the current byte contents - note this operates on the internal dataintsize()toString()voidwrite(byte[] b, int off, int len) Writeslenbytes from the specified byte array starting at offsetoffto this byte array output stream.voidwrite(int b) Writes the specified byte to this byte array output stream.Methods inherited from class org.cip4.jdflib.util.ByteArrayIOStream
getBuf, getBufferedInputStream, getNewStreamMethods inherited from class java.io.ByteArrayOutputStream
reset, toByteArray, toString, toString, toString, writeBytes, writeToMethods inherited from class java.io.OutputStream
flush, nullOutputStream, write
-
Constructor Details
-
ByteArrayIOFileStream
public ByteArrayIOFileStream(long maxLength) creates an empty input output stream class- Parameters:
maxLength- the maximum length in memory
-
ByteArrayIOFileStream
creates an input output stream class from any stream if is already is a buffered inputstream, no copy is made- Parameters:
is- the inputstream to buffermaxLength- the maximum length in memory
-
ByteArrayIOFileStream
create a ByteArrayIOStream from a file- Parameters:
f- the filemaxLength- the maximum length in memoryreadOnly-- Throws:
IOException
-
-
Method Details
-
getBufferedInputStream
public static ByteArrayIOStream.ByteArrayIOInputStream getBufferedInputStream(InputStream is, long maxLen) get a completely buffered and resizable input stream- Parameters:
is-- Returns:
-
getInputStream
gets an input stream based on the current byte contents - note this operates on the internal data- Overrides:
getInputStreamin classByteArrayIOStream- Returns:
- an input stream
-
write
public void write(int b) Writes the specified byte to this byte array output stream.- Overrides:
writein classByteArrayOutputStream- Parameters:
b- the byte to be written.
-
write
public void write(byte[] b, int off, int len) Writeslenbytes from the specified byte array starting at offsetoffto this byte array output stream.- Overrides:
writein classByteArrayOutputStream- Parameters:
b- the data.off- the start offset in the data.len- the number of bytes to write.
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classByteArrayIOStream- See Also:
-
finalize
-
size
public int size()- Overrides:
sizein classByteArrayOutputStream- Returns:
-
getFile
- Returns:
- the file
-
toString
- Overrides:
toStringin classByteArrayIOStream- See Also:
-