Package nom.tam.util
Class ArrayOutputStream
java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
java.io.BufferedOutputStream
nom.tam.util.ArrayOutputStream
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
,OutputWriter
- Direct Known Subclasses:
FitsOutputStream
Efficient writing of binary arrays to streams with custom binary encoding.
- Since:
- 1.16
- Author:
- Attila Kovacs
- See Also:
-
Field Summary
Fields inherited from class java.io.BufferedOutputStream
buf, count
Fields inherited from class java.io.FilterOutputStream
out
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
ArrayOutputStream
(OutputStream o, int bufLength) Instantiates a new output stream for efficient array transactions.ArrayOutputStream
(OutputStream o, int bufLength, OutputEncoder java2bin) Instantiates a new output stream for efficient array transactions. -
Method Summary
Modifier and TypeMethodDescriptionprotected OutputEncoder
Returns the conversion from Java arrays to their binary representation in the stream.protected void
setEncoder
(OutputEncoder java2bin) Sets the conversion from Java arrays to their binary representation in the stream.void
writeArray
(Object o) SeeArrayDataOutput.writeArray(Object)
for a contract of this method.Methods inherited from class java.io.BufferedOutputStream
flush, write, write
Methods inherited from class java.io.FilterOutputStream
close, write
Methods inherited from class java.io.OutputStream
nullOutputStream
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface nom.tam.util.OutputWriter
write, write
-
Constructor Details
-
ArrayOutputStream
Instantiates a new output stream for efficient array transactions. For use by subclass constructors only.- Parameters:
o
- the underlying output streambufLength
- the buffer size in bytes.
-
ArrayOutputStream
Instantiates a new output stream for efficient array transactions.- Parameters:
o
- the underlying output streambufLength
- the buffer size in bytes.java2bin
- the conversion from Java arrays to the binary representation in the stream.
-
-
Method Details
-
setEncoder
Sets the conversion from Java arrays to their binary representation in the stream. For use by subclass constructors only.- Parameters:
java2bin
- the conversion from Java arrays to their binary representation in stream- See Also:
-
getEncoder
Returns the conversion from Java arrays to their binary representation in the stream. Subclass implementeations can use this to access the required conversion when writing data to file.- Returns:
- the conversion from Java arrays to their binary representation in stream
- See Also:
-
writeArray
SeeArrayDataOutput.writeArray(Object)
for a contract of this method.- Parameters:
o
- an array ot any type.- Throws:
IllegalArgumentException
- if the argument is not an array or if it contains an element that is not supported for encoding.IOException
- if there was an IO error writing to the output.
-