Class ImageInputStreamImpl
java.lang.Object
javax.imageio.stream.ImageInputStreamImpl
- All Implemented Interfaces:
Closeable
,DataInput
,AutoCloseable
,ImageInputStream
- Direct Known Subclasses:
FileCacheImageInputStream
,FileImageInputStream
,ImageOutputStreamImpl
,MemoryCacheImageInputStream
An abstract class implementing the
ImageInputStream
interface.
This class is designed to reduce the number of methods that must
be implemented by subclasses.
In particular, this class handles most or all of the details of byte order interpretation, buffering, mark/reset, discarding, closing, and disposing.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected int
The current bit offset within the stream.protected ByteOrder
The byte order of the stream as an instance of the enumeration classjava.nio.ByteOrder
, whereByteOrder.BIG_ENDIAN
indicates network byte order andByteOrder.LITTLE_ENDIAN
indicates the reverse order.protected long
The position prior to which data may be discarded.protected long
The current read position within the stream. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected final void
Throws anIOException
if the stream has been closed.void
close()
Closes the stream.protected void
finalize()
Deprecated, for removal: This API element is subject to removal in a future version.Finalization has been deprecated for removal.void
flush()
Discards the initial position of the stream prior to the current stream position.void
flushBefore
(long pos) Discards the initial portion of the stream prior to the indicated position.int
Returns the current bit offset, as an integer between 0 and 7, inclusive.Returns the byte order with which data values will be read from this stream as an instance of thejava.nio.ByteOrder
enumeration.long
Returns the earliest position in the stream to which seeking may be performed.long
Returns the current byte position of the stream.boolean
isCached()
Default implementation returns false.boolean
Default implementation returns false.boolean
Default implementation returns false.long
length()
Returns-1L
to indicate that the stream has unknown length.void
mark()
Pushes the current stream position onto a stack of marked positions.abstract int
read()
Reads a single byte from the stream and returns it as anint
between 0 and 255.int
read
(byte[] b) A convenience method that callsread(b, 0, b.length)
.abstract int
read
(byte[] b, int off, int len) Reads up tolen
bytes from the stream, and stores them intob
starting at indexoff
.int
readBit()
Reads a single bit from the stream and returns it as anint
with the value0
or1
.long
readBits
(int numBits) Reads a bitstring from the stream and returns it as along
, with the first bit read becoming the most significant bit of the output.boolean
Reads a byte from the stream and returns aboolean
value oftrue
if it is nonzero,false
if it is zero.byte
readByte()
Reads a byte from the stream and returns it as abyte
value.void
readBytes
(IIOByteBuffer buf, int len) Reads up tolen
bytes from the stream, and modifies the suppliedIIOByteBuffer
to indicate the byte array, offset, and length where the data may be found.char
readChar()
Equivalent toreadUnsignedShort
, except that the result is returned using thechar
datatype.double
Reads 8 bytes from the stream, and (conceptually) concatenates them according to the current byte order and returns the result as adouble
.float
Reads 4 bytes from the stream, and (conceptually) concatenates them according to the current byte order and returns the result as afloat
.void