Package nom.tam.util
Class ArrayInputStream
java.lang.Object
java.io.InputStream
java.io.FilterInputStream
java.io.BufferedInputStream
nom.tam.util.ArrayInputStream
- All Implemented Interfaces:
Closeable
,AutoCloseable
,InputReader
- Direct Known Subclasses:
FitsInputStream
Efficient reading of binary arrays from streams with custom binary encoding.
- Since:
- 1.16
- Author:
- Attila Kovacs
- See Also:
-
Field Summary
Fields inherited from class java.io.FilterInputStream
in
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
ArrayInputStream
(InputStream i, int bufLength) Instantiates a new input stream for efficient array transactions. -
Method Summary
Modifier and TypeMethodDescriptionprotected InputDecoder
Returns the conversion from the binary representation of arrays in stream to Java arrays.void
SeeArrayDataInput.readArrayFully(Object)
for a contract of this method.void
LikereadArrayFully(Object)
but strictly for numerical types only.long
readLArray
(Object o) SeeArrayDataInput.readLArray(Object)
for a contract of this method.protected void
setDecoder
(InputDecoder bin2java) Sets the conversion from the binary representation of arrays in stream to Java arrays.Methods inherited from class java.io.BufferedInputStream
available, close, mark, markSupported, read, read, reset, skip
Methods inherited from class java.io.FilterInputStream
read
Methods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
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.InputReader
read, read
-
Constructor Details
-
ArrayInputStream
Instantiates a new input stream for efficient array transactions. For use by subclass constructors only.- Parameters:
i
- the underlying input streambufLength
- the buffer size in bytes.
-
-
Method Details
-
setDecoder
Sets the conversion from the binary representation of arrays in stream to Java arrays. For use by subclass constructors only.- Parameters:
bin2java
- the conversion from the binary representation of arrays in the stream to Java arrays.- See Also:
-
getDecoder
Returns the conversion from the binary representation of arrays in stream to Java arrays. Subclass implementeations can use this to access the required conversion when writing data to file.- Returns:
- the conversion from the binary representation of arrays in the stream to Java arrays
- See Also:
-
readLArray
SeeArrayDataInput.readLArray(Object)
for a contract of this method.- Parameters:
o
- an array, to be populated- Returns:
- the actual number of bytes read from the input, or -1 if already at the end-of-file.
- Throws:
IllegalArgumentException
- if the argument is not an array or if it contains an element that is not supported for decoding.IOException
- if there was an IO error reading from the input- See Also:
-
readArrayFully
SeeArrayDataInput.readArrayFully(Object)
for a contract of this method.- Parameters:
o
- an array, to be populated- Throws:
IllegalArgumentException
- if the argument is not an array or if it contains an element that is not supported for decoding.IOException
- if there was an IO error reading from the input- See Also:
-
readImage
LikereadArrayFully(Object)
but strictly for numerical types only.- Parameters:
o
- An any-dimensional array containing only numerical types- Throws:
IllegalArgumentException
- if the argument is not an array or if it contains an element that is not supported.EOFException
- if already at the end of file.IOException
- if there was an IO error- Since:
- 1.18
- See Also:
-