0N/A/*
3261N/A * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage javax.imageio.stream;
0N/A
2548N/Aimport java.io.Closeable;
0N/Aimport java.io.DataInput;
0N/Aimport java.io.IOException;
0N/Aimport java.nio.ByteOrder;
0N/A
0N/A/**
0N/A * A seekable input stream interface for use by
0N/A * <code>ImageReader</code>s. Various input sources, such as
0N/A * <code>InputStream</code>s and <code>File</code>s,
0N/A * as well as future fast I/O sources may be "wrapped" by a suitable
0N/A * implementation of this interface for use by the Image I/O API.
0N/A *
0N/A * @see ImageInputStreamImpl
0N/A * @see FileImageInputStream
0N/A * @see FileCacheImageInputStream
0N/A * @see MemoryCacheImageInputStream
0N/A *
0N/A */
2548N/Apublic interface ImageInputStream extends DataInput, Closeable {
0N/A
0N/A /**
0N/A * Sets the desired byte order for future reads of data values
0N/A * from this stream. For example, the sequence of bytes '0x01
0N/A * 0x02 0x03 0x04' if read as a 4-byte integer would have the
0N/A * value '0x01020304' using network byte order and the value
0N/A * '0x04030201' under the reverse byte order.
0N/A *
0N/A * <p> The enumeration class <code>java.nio.ByteOrder</code> is
0N/A * used to specify the byte order. A value of
0N/A * <code>ByteOrder.BIG_ENDIAN</code> specifies so-called
0N/A * big-endian or network byte order, in which the high-order byte
0N/A * comes first. Motorola and Sparc processors store data in this
0N/A * format, while Intel processors store data in the reverse
0N/A * <code>ByteOrder.LITTLE_ENDIAN</code> order.
0N/A *
0N/A * <p> The byte order has no effect on the results returned from
0N/A * the <code>readBits</code> method (or the value written by
0N/A * <code>ImageOutputStream.writeBits</code>).
0N/A *
0N/A * @param byteOrder one of <code>ByteOrder.BIG_ENDIAN</code> or
0N/A * <code>java.nio.ByteOrder.LITTLE_ENDIAN</code>, indicating whether
0N/A * network byte order or its reverse will be used for future
0N/A * reads.
0N/A *
0N/A * @see java.nio.ByteOrder
0N/A * @see #getByteOrder
0N/A * @see #readBits(int)
0N/A */
0N/A void setByteOrder(ByteOrder byteOrder);
0N/A
0N/A /**
0N/A * Returns the byte order with which data values will be read from
0N/A * this stream as an instance of the
0N/A * <code>java.nio.ByteOrder</code> enumeration.
0N/A *
0N/A * @return one of <code>ByteOrder.BIG_ENDIAN</code> or
0N/A * <code>ByteOrder.LITTLE_ENDIAN</code>, indicating which byte
0N/A * order is being used.
0N/A *
0N/A * @see java.nio.ByteOrder
0N/A * @see #setByteOrder
0N/A */
0N/A ByteOrder getByteOrder();
0N/A
0N/A /**
0N/A * Reads a single byte from the stream and returns it as an
0N/A * integer between 0 and 255. If the end of the stream is
0N/A * reached, -1 is returned.
0N/A *
0N/A * <p> The bit offset within the stream is reset to zero before
0N/A * the read occurs.
0N/A *
0N/A * @return a byte value from the stream, as an int, or -1 to
0N/A * indicate EOF.
0N/A *
0N/A * @exception IOException if an I/O error occurs.
0N/A */
0N/A int read() throws IOException;
0N/A
0N/A /**
0N/A * Reads up to <code>b.length</code> bytes from the stream, and
0N/A * stores them into <code>b</code> starting at index 0. The
0N/A * number of bytes read is returned. If no bytes can be read
0N/A * because the end of the stream has been reached, -1 is returned.
0N/A *
0N/A * <p> The bit offset within the stream is reset to zero before
0N/A * the read occurs.
0N/A *
0N/A * @param b an array of bytes to be written to.
0N/A *
0N/A * @return the number of bytes actually read, or <code>-1</code>
0N/A * to indicate EOF.
0N/A *
0N/A * @exception NullPointerException if <code>b</code> is
0N/A * <code>null</code>.
0N/A *
0N/A * @exception IOException if an I/O error occurs.
0N/A */
0N/A int read(byte[] b) throws IOException;
0N/A
0N/A /**
0N/A * Reads up to <code>len</code> bytes from the stream, and stores
0N/A * them into <code>b</code> starting at index <code>off</code>.
0N/A * The number of bytes read is returned. If no bytes can be read
0N/A * because the end of the stream has been reached, <code>-1</code>
0N/A * is returned.
0N/A *
0N/A * <p> The bit offset within the stream is reset to zero before
0N/A * the read occurs.
0N/A *
0N/A * @param b an array of bytes to be written to.
0N/A * @param off the starting position within <code>b</code> to write to.
0N/A * @param len the maximum number of <code>byte</code>s to read.
0N/A *
0N/A * @return the number of bytes actually read, or <code>-1</code>
0N/A * to indicate EOF.
0N/A *
0N/A * @exception NullPointerException if <code>b</code> is
0N/A * <code>null</code>.
0N/A * @exception IndexOutOfBoundsException if <code>off</code> is
0N/A * negative, <code>len</code> is negative, or <code>off +
0N/A * len</code> is greater than <code>b.length</code>.
0N/A * @exception IOException if an I/O error occurs.
0N/A */
0N/A int read(byte[] b, int off, int len) throws IOException;
0N/A
0N/A /**
0N/A * Reads up to <code>len</code> bytes from the stream, and
0N/A * modifies the supplied <code>IIOByteBuffer</code> to indicate
0N/A * the byte array, offset, and length where the data may be found.
0N/A * The caller should not attempt to modify the data found in the
0N/A * <code>IIOByteBuffer</code>.
0N/A *
0N/A * <p> The bit offset within the stream is reset to zero before
0N/A * the read occurs.
0N/A *
0N/A * @param buf an IIOByteBuffer object to be modified.
0N/A * @param len the maximum number of <code>byte</code>s to read.
0N/A *
0N/A * @exception IndexOutOfBoundsException if <code>len</code> is
0N/A * negative.
0N/A * @exception NullPointerException if <code>buf</code> is
0N/A * <code>null</code>.
0N/A *
0N/A * @exception IOException if an I/O error occurs.
0N/A */
0N/A void readBytes(IIOByteBuffer buf, int len) throws IOException;
0N/A
0N/A /**
0N/A * Reads a byte from the stream and returns a <code>boolean</code>
0N/A * value of <code>true</code> if it is nonzero, <code>false</code>
0N/A * if it is zero.
0N/A *
0N/A * <p> The bit offset within the stream is reset to zero before
0N/A * the read occurs.
0N/A *
0N/A * @return a boolean value from the stream.
0N/A *
0N/A * @exception EOFException if the end of the stream is reached.
0N/A * @exception IOException if an I/O error occurs.
0N/A */
0N/A boolean readBoolean() throws IOException;
0N/A
0N/A /**
0N/A * Reads a byte from the stream and returns it as a
0N/A * <code>byte</code> value. Byte values between <code>0x00</code>
0N/A * and <code>0x7f</code> represent integer values between
0N/A * <code>0</code> and <code>127</code>. Values between
0N/A * <code>0x80</code> and <code>0xff</code> represent negative
0N/A * values from <code>-128</code> to <code>/1</code>.
0N/A *
0N/A * <p> The bit offset within the stream is reset to zero before
0N/A * the read occurs.
0N/A *
0N/A * @return a signed byte value from the stream.
0N/A *
0N/A * @exception EOFException if the end of the stream is reached.
0N/A * @exception IOException if an I/O error occurs.
0N/A */
0N/A byte readByte() throws IOException;
0N/A
0N/A /**
0N/A * Reads a byte from the stream, and (conceptually) converts it to
0N/A * an int, masks it with <code>0xff</code> in order to strip off
0N/A * any sign-extension bits, and returns it as a <code>byte</code>
0N/A * value.
0N/A *
0N/A * <p> Thus, byte values between <code>0x00</code> and
0N/A * <code>0x7f</code> are simply returned as integer values between
0N/A * <code>0</code> and <code>127</code>. Values between
0N/A * <code>0x80</code> and <code>0xff</code>, which normally
0N/A * represent negative <code>byte</code>values, will be mapped into
0N/A * positive integers between <code>128</code> and
0N/A * <code>255</code>.
0N/A *
0N/A * <p> The bit offset within the stream is reset to zero before
0N/A * the read occurs.
0N/A *
0N/A * @return an unsigned byte value from the stream.
0N/A *
0N/A * @exception EOFException if the end of the stream is reached.
0N/A * @exception IOException if an I/O error occurs.
0N/A */
0N/A int readUnsignedByte() throws IOException;
0N/A
0N/A /**
0N/A * Reads two bytes from the stream, and (conceptually)
0N/A * concatenates them according to the current byte order, and
0N/A * returns the result as a <code>short</code> value.
0N/A *
0N/A * <p> The bit offset within the stream is reset to zero before
0N/A * the read occurs.
0N/A *
0N/A * @return a signed short value from the stream.
0N/A *
0N/A * @exception EOFException if the stream reaches the end before
0N/A * reading all the bytes.
0N/A * @exception IOException if an I/O error occurs.
0N/A *
0N/A * @see #getByteOrder
0N/A */
0N/A short readShort() throws IOException;
0N/A
0N/A /**
0N/A * Reads two bytes from the stream, and (conceptually)
0N/A * concatenates them according to the current byte order, converts
0N/A * the resulting value to an <code>int</code>, masks it with
0N/A * <code>0xffff</code> in order to strip off any sign-extension
0N/A * buts, and returns the result as an unsigned <code>int</code>
0N/A * value.
0N/A *
0N/A * <p> The bit offset within the stream is reset to zero before
0N/A * the read occurs.
0N/A *
0N/A * @return an unsigned short value from the stream, as an int.
0N/A *
0N/A * @exception EOFException if the stream reaches the end before
0N/A * reading all the bytes.
0N/A * @exception IOException if an I/O error occurs.
0N/A *
0N/A * @see #getByteOrder
0N/A */
0N/A int readUnsignedShort() throws IOException;
0N/A
0N/A /**
0N/A * Equivalent to <code>readUnsignedShort</code>, except that the
0N/A * result is returned using the <code>char</code> datatype.
0N/A *
0N/A * <p> The bit offset within the stream is reset to zero before
0N/A * the read occurs.
0N/A *
0N/A * @return an unsigned char value from the stream.
0N/A *
0N/A * @exception EOFException if the stream reaches the end before
0N/A * reading all the bytes.
0N/A * @exception IOException if an I/O error occurs.
0N/A *
0N/A * @see #readUnsignedShort
0N/A */
0N/A char readChar() throws IOException;
0N/A
0N/A /**
0N/A * Reads 4 bytes from the stream, and (conceptually) concatenates
0N/A * them according to the current byte order and returns the result
0N/A * as an <code>int</code>.
0N/A *
0N/A * <p> The bit offset within the stream is ignored and treated as
0N/A * though it were zero.
0N/A *
0N/A * @return a signed int value from the stream.
0N/A *
0N/A * @exception EOFException if the stream reaches the end before
0N/A * reading all the bytes.
0N/A * @exception IOException if an I/O error occurs.
0N/A *
0N/A * @see #getByteOrder
0N/A */
0N/A int readInt() throws IOException;
0N/A
0N/A /**
0N/A * Reads 4 bytes from the stream, and (conceptually) concatenates
0N/A * them according to the current byte order, converts the result
0N/A * to a long, masks it with <code>0xffffffffL</code> in order to
0N/A * strip off any sign-extension bits, and returns the result as an
0N/A * unsigned <code>long</code> value.
0N/A *
0N/A * <p> The bit offset within the stream is reset to zero before
0N/A * the read occurs.
0N/A *
0N/A * @return an unsigned int value from the stream, as a long.
0N/A *
0N/A * @exception EOFException if the stream reaches the end before
0N/A * reading all the bytes.
0N/A * @exception IOException if an I/O error occurs.
0N/A *
0N/A * @see #getByteOrder
0N/A */
0N/A long readUnsignedInt() throws IOException;
0N/A
0N/A /**
0N/A * Reads 8 bytes from the stream, and (conceptually) concatenates
0N/A * them according to the current byte order and returns the result
0N/A * as a <code>long</code>.
0N/A *
0N/A * <p> The bit offset within the stream is reset to zero before
0N/A * the read occurs.
0N/A *
0N/A * @return a signed long value from the stream.
0N/A *
0N/A * @exception EOFException if the stream reaches the end before
0N/A * reading all the bytes.
0N/A * @exception IOException if an I/O error occurs.
0N/A *
0N/A * @see #getByteOrder
0N/A */
0N/A long readLong() throws IOException;
0N/A
0N/A /**
0N/A * Reads 4 bytes from the stream, and (conceptually) concatenates
0N/A * them according to the current byte order and returns the result
0N/A * as a <code>float</code>.
0N/A *
0N/A * <p> The bit offset within the stream is reset to zero before
0N/A * the read occurs.
0N/A *
0N/A * @return a float value from the stream.
0N/A *
0N/A * @exception EOFException if the stream reaches the end before
0N/A * reading all the bytes.
0N/A * @exception IOException if an I/O error occurs.
0N/A *
0N/A * @see #getByteOrder
0N/A */
0N/A float readFloat() throws IOException;
0N/A
0N/A /**
0N/A * Reads 8 bytes from the stream, and (conceptually) concatenates
0N/A * them according to the current byte order and returns the result
0N/A * as a <code>double</code>.
0N/A *
0N/A * <p> The bit offset within the stream is reset to zero before
0N/A * the read occurs.
0N/A *
0N/A * @return a double value from the stream.
0N/A *
0N/A * @exception EOFException if the stream reaches the end before
0N/A * reading all the bytes.
0N/A * @exception IOException if an I/O error occurs.
0N/A *
0N/A * @see #getByteOrder
0N/A */
0N/A double readDouble() throws IOException;
0N/A
0N/A /**
0N/A * Reads the next line of text from the input stream. It reads
0N/A * successive bytes, converting each byte separately into a
0N/A * character, until it encounters a line terminator or end of
0N/A * file; the characters read are then returned as a
0N/A * <code>String</code>. Note that because this method processes
0N/A * bytes, it does not support input of the full Unicode character
0N/A * set.
0N/A *
0N/A * <p> If end of file is encountered before even one byte can be
0N/A * read, then <code>null</code> is returned. Otherwise, each byte
0N/A * that is read is converted to type <code>char</code> by
0N/A * zero-extension. If the character <code>'\n'</code> is
0N/A * encountered, it is discarded and reading ceases. If the
0N/A * character <code>'\r'</code> is encountered, it is discarded
0N/A * and, if the following byte converts &#32;to the character
0N/A * <code>'\n'</code>, then that is discarded also; reading then
0N/A * ceases. If end of file is encountered before either of the
0N/A * characters <code>'\n'</code> and <code>'\r'</code> is
0N/A * encountered, reading ceases. Once reading has ceased, a
0N/A * <code>String</code> is returned that contains all the
0N/A * characters read and not discarded, taken in order. Note that
0N/A * every character in this string will have a value less than
0N/A * <code>&#92;u0100</code>, that is, <code>(char)256</code>.
0N/A *
0N/A * <p> The bit offset within the stream is reset to zero before
0N/A * the read occurs.
0N/A *
0N/A * @return a String containing a line of text from the stream.
0N/A *
0N/A * @exception IOException if an I/O error occurs.
0N/A */
0N/A String readLine() throws IOException;
0N/A
0N/A /**
0N/A * Reads in a string that has been encoded using a
0N/A * <a href="../../../java/io/DataInput.html#modified-utf-8">modified
0N/A * UTF-8</a>
0N/A * format. The general contract of <code>readUTF</code> is that
0N/A * it reads a representation of a Unicode character string encoded
0N/A * in modified UTF-8 format; this string of characters is
0N/A * then returned as a <code>String</code>.
0N/A *
0N/A * <p> First, two bytes are read and used to construct an unsigned
0N/A * 16-bit integer in the manner of the
0N/A * <code>readUnsignedShort</code> method, using network byte order
0N/A * (regardless of the current byte order setting). This integer
0N/A * value is called the <i>UTF length</i> and specifies the number
0N/A * of additional bytes to be read. These bytes are then converted
0N/A * to characters by considering them in groups. The length of each
0N/A * group is computed from the value of the first byte of the
0N/A * group. The byte following a group, if any, is the first byte of
0N/A * the next group.
0N/A *
0N/A * <p> If the first byte of a group matches the bit pattern
0N/A * <code>0xxxxxxx</code> (where <code>x</code> means "may be
0N/A * <code>0</code> or <code>1</code>"), then the group consists of
0N/A * just that byte. The byte is zero-extended to form a character.
0N/A *
0N/A * <p> If the first byte of a group matches the bit pattern
0N/A * <code>110xxxxx</code>, then the group consists of that byte
0N/A * <code>a</code> and a second byte <code>b</code>. If there is no
0N/A * byte <code>b</code> (because byte <code>a</code> was the last
0N/A * of the bytes to be read), or if byte <code>b</code> does not
0N/A * match the bit pattern <code>10xxxxxx</code>, then a
0N/A * <code>UTFDataFormatException</code> is thrown. Otherwise, the
0N/A * group is converted to the character:
0N/A *
0N/A * <p> <pre><code>
0N/A * (char)(((a&amp; 0x1F) &lt;&lt; 6) | (b &amp; 0x3F))
0N/A * </code></pre>
0N/A *
0N/A * If the first byte of a group matches the bit pattern
0N/A * <code>1110xxxx</code>, then the group consists of that byte
0N/A * <code>a</code> and two more bytes <code>b</code> and
0N/A * <code>c</code>. If there is no byte <code>c</code> (because
0N/A * byte <code>a</code> was one of the last two of the bytes to be
0N/A * read), or either byte <code>b</code> or byte <code>c</code>
0N/A * does not match the bit pattern <code>10xxxxxx</code>, then a
0N/A * <code>UTFDataFormatException</code> is thrown. Otherwise, the
0N/A * group is converted to the character:
0N/A *
0N/A * <p> <pre><code>
0N/A * (char)(((a &amp; 0x0F) &lt;&lt; 12) | ((b &amp; 0x3F) &lt;&lt; 6) | (c &amp; 0x3F))
0N/A * </code></pre>
0N/A *
0N/A * If the first byte of a group matches the pattern
0N/A * <code>1111xxxx</code> or the pattern <code>10xxxxxx</code>,
0N/A * then a <code>UTFDataFormatException</code> is thrown.
0N/A *
0N/A * <p> If end of file is encountered at any time during this
0N/A * entire process, then an <code>EOFException</code> is thrown.
0N/A *
0N/A * <p> After every group has been converted to a character by this
0N/A * process, the characters are gathered, in the same order in
0N/A * which their corresponding groups were read from the input
0N/A * stream, to form a <code>String</code>, which is returned.
0N/A *
0N/A * <p> The current byte order setting is ignored.
0N/A *
0N/A * <p> The bit offset within the stream is reset to zero before
0N/A * the read occurs.
0N/A *
0N/A * <p><strong>Note:</strong> This method should not be used in
0N/A * the implementation of image formats that use standard UTF-8,
0N/A * because the modified UTF-8 used here is incompatible with
0N/A * standard UTF-8.
0N/A *
0N/A * @return a String read from the stream.
0N/A *
0N/A * @exception EOFException if this stream reaches the end
0N/A * before reading all the bytes.
0N/A * @exception UTFDataFormatException if the bytes do not represent a
0N/A * valid modified UTF-8 encoding of a string.
0N/A * @exception IOException if an I/O error occurs.
0N/A */
0N/A String readUTF() throws IOException;
0N/A
0N/A /**
0N/A * Reads <code>len</code> bytes from the stream, and stores them
0N/A * into <code>b</code> starting at index <code>off</code>.
0N/A * If the end of the stream is reached, an <code>EOFException</code>
0N/A * will be thrown.
0N/A *
0N/A * <p> The bit offset within the stream is reset to zero before
0N/A * the read occurs.
0N/A *
0N/A * @param b an array of bytes to be written to.
0N/A * @param off the starting position within <code>b</code> to write to.
0N/A * @param len the maximum number of <code>byte</code>s to read.
0N/A *
0N/A * @exception IndexOutOfBoundsException if <code>off</code> is
0N/A * negative, <code>len</code> is negative, or <code>off +
0N/A * len</code> is greater than <code>b.length</code>.
0N/A * @exception NullPointerException if <code>b</code> is
0N/A * <code>null</code>.
0N/A * @exception EOFException if the stream reaches the end before
0N/A * reading all the bytes.
0N/A * @exception IOException if an I/O error occurs.
0N/A */
0N/A void readFully(byte[] b, int off, int len) throws IOException;
0N/A
0N/A /**
0N/A * Reads <code>b.length</code> bytes from the stream, and stores them
0N/A * into <code>b</code> starting at index <code>0</code>.
0N/A * If the end of the stream is reached, an <code>EOFException</code>
0N/A * will be thrown.
0N/A *
0N/A * <p> The bit offset within the stream is reset to zero before
0N/A * the read occurs.
0N/A *
0N/A * @param b an array of <code>byte</code>s.
0N/A *
0N/A * @exception NullPointerException if <code>b</code> is
0N/A * <code>null</code>.
0N/A * @exception EOFException if the stream reaches the end before
0N/A * reading all the bytes.
0N/A * @exception IOException if an I/O error occurs.
0N/A */
0N/A void readFully(byte[] b) throws IOException;
0N/A
0N/A /**
0N/A * Reads <code>len</code> shorts (signed 16-bit integers) from the
0N/A * stream according to the current byte order, and
0N/A * stores them into <code>s</code> starting at index
0N/A * <code>off</code>. If the end of the stream is reached, an
0N/A * <code>EOFException</code> will be thrown.
0N/A *
0N/A * <p> The bit offset within the stream is reset to zero before
0N/A * the read occurs.
0N/A *
0N/A * @param s an array of shorts to be written to.
0N/A * @param off the starting position withinb to write to.
0N/A * @param len the maximum number of <code>short</code>s to read.
0N/A *
0N/A * @exception IndexOutOfBoundsException if <code>off</code> is
0N/A * negative, <code>len</code> is negative, or <code>off +
0N/A * len</code> is greater than <code>s.length</code>.
0N/A * @exception NullPointerException if <code>s</code> is
0N/A * <code>null</code>.
0N/A * @exception EOFException if the stream reaches the end before
0N/A * reading all the bytes.
0N/A * @exception IOException if an I/O error occurs.
0N/A */
0N/A void readFully(short[] s, int off, int len) throws IOException;
0N/A
0N/A /**
0N/A * Reads <code>len</code> chars (unsigned 16-bit integers) from the
0N/A * stream according to the current byte order, and
0N/A * stores them into <code>c</code> starting at index
0N/A * <code>off</code>. If the end of the stream is reached, an
0N/A * <code>EOFException</code> will be thrown.
0N/A *
0N/A * <p> The bit offset within the stream is reset to zero before
0N/A * the read occurs.
0N/A *
0N/A * @param c an array of chars to be written to.
0N/A * @param off the starting position withinb to write to.
0N/A * @param len the maximum number of <code>char</code>s to read.
0N/A *
0N/A * @exception IndexOutOfBoundsException if <code>off</code> is
0N/A * negative, <code>len</code> is negative, or <code>off +
0N/A * len</code> is greater than <code>c.length</code>.
0N/A * @exception NullPointerException if <code>c</code> is
0N/A * <code>null</code>.
0N/A * @exception EOFException if the stream reaches the end before
0N/A * reading all the bytes.
0N/A * @exception IOException if an I/O error occurs.
0N/A */
0N/A void readFully(char[] c, int off, int len) throws IOException;
0N/A
0N/A /**
0N/A * Reads <code>len</code> ints (signed 32-bit integers) from the
0N/A * stream according to the current byte order, and
0N/A * stores them into <code>i</code> starting at index
0N/A * <code>off</code>. If the end of the stream is reached, an
0N/A * <code>EOFException</code> will be thrown.
0N/A *
0N/A * <p> The bit offset within the stream is reset to zero before
0N/A * the read occurs.
0N/A *
0N/A * @param i an array of ints to be written to.
0N/A * @param off the starting position withinb to write to.
0N/A * @param len the maximum number of <code>int</code>s to read.
0N/A *
0N/A * @exception IndexOutOfBoundsException if <code>off</code> is
0N/A * negative, <code>len</code> is negative, or <code>off +
0N/A * len</code> is greater than <code>i.length</code>.
0N/A * @exception NullPointerException if <code>i</code> is
0N/A * <code>null</code>.
0N/A * @exception EOFException if the stream reaches the end before
0N/A * reading all the bytes.
0N/A * @exception IOException if an I/O error occurs.
0N/A */
0N/A void readFully(int[] i, int off, int len) throws IOException;
0N/A
0N/A /**
0N/A * Reads <code>len</code> longs (signed 64-bit integers) from the
0N/A * stream according to the current byte order, and
0N/A * stores them into <code>l</code> starting at index
0N/A * <code>off</code>. If the end of the stream is reached, an
0N/A * <code>EOFException</code> will be thrown.
0N/A *
0N/A * <p> The bit offset within the stream is reset to zero before
0N/A * the read occurs.
0N/A *
0N/A * @param l an array of longs to be written to.
0N/A * @param off the starting position withinb to write to.
0N/A * @param len the maximum number of <code>long</code>s to read.
0N/A *
0N/A * @exception IndexOutOfBoundsException if <code>off</code> is
0N/A * negative, <code>len</code> is negative, or <code>off +
0N/A * len</code> is greater than <code>l.length</code>.
0N/A * @exception NullPointerException if <code>l</code> is
0N/A * <code>null</code>.
0N/A * @exception EOFException if the stream reaches the end before
0N/A * reading all the bytes.
0N/A * @exception IOException if an I/O error occurs.
0N/A */
0N/A void readFully(long[] l, int off, int len) throws IOException;
0N/A
0N/A /**
0N/A * Reads <code>len</code> floats (32-bit IEEE single-precision
0N/A * floats) from the stream according to the current byte order,
0N/A * and stores them into <code>f</code> starting at
0N/A * index <code>off</code>. If the end of the stream is reached,
0N/A * an <code>EOFException</code> will be thrown.
0N/A *
0N/A * <p> The bit offset within the stream is reset to zero before
0N/A * the read occurs.
0N/A *
0N/A * @param f an array of floats to be written to.
0N/A * @param off the starting position withinb to write to.
0N/A * @param len the maximum number of <code>float</code>s to read.
0N/A *
0N/A * @exception IndexOutOfBoundsException if <code>off</code> is
0N/A * negative, <code>len</code> is negative, or <code>off +
0N/A * len</code> is greater than <code>f.length</code>.
0N/A * @exception NullPointerException if <code>f</code> is
0N/A * <code>null</code>.
0N/A * @exception EOFException if the stream reaches the end before
0N/A * reading all the bytes.
0N/A * @exception IOException if an I/O error occurs.
0N/A */
0N/A void readFully(float[] f, int off, int len) throws IOException;
0N/A
0N/A /**
0N/A * Reads <code>len</code> doubles (64-bit IEEE double-precision
0N/A * floats) from the stream according to the current byte order,
0N/A * and stores them into <code>d</code> starting at
0N/A * index <code>off</code>. If the end of the stream is reached,
0N/A * an <code>EOFException</code> will be thrown.
0N/A *
0N/A * <p> The bit offset within the stream is reset to zero before
0N/A * the read occurs.
0N/A *
0N/A * @param d an array of doubles to be written to.
0N/A * @param off the starting position withinb to write to.
0N/A * @param len the maximum number of <code>double</code>s to read.
0N/A *
0N/A * @exception IndexOutOfBoundsException if <code>off</code> is
0N/A * negative, <code>len</code> is negative, or <code>off +
0N/A * len</code> is greater than <code>d.length</code>.
0N/A * @exception NullPointerException if <code>d</code> is
0N/A * <code>null</code>.
0N/A * @exception EOFException if the stream reaches the end before
0N/A * reading all the bytes.
0N/A * @exception IOException if an I/O error occurs.
0N/A */
0N/A void readFully(double[] d, int off, int len) throws IOException;
0N/A
0N/A /**
0N/A * Returns the current byte position of the stream. The next read
0N/A * will take place starting at this offset.
0N/A *
0N/A * @return a long containing the position of the stream.
0N/A *
0N/A * @exception IOException if an I/O error occurs.
0N/A */
0N/A long getStreamPosition() throws IOException;
0N/A
0N/A /**
0N/A * Returns the current bit offset, as an integer between 0 and 7,
0N/A * inclusive. The bit offset is updated implicitly by calls to
0N/A * the <code>readBits</code> method. A value of 0 indicates the
0N/A * most-significant bit, and a value of 7 indicates the least
0N/A * significant bit, of the byte being read.
0N/A *
0N/A * <p> The bit offset is set to 0 when a stream is first
0N/A * opened, and is reset to 0 by calls to <code>seek</code>,
0N/A * <code>skipBytes</code>, or any <code>read</code> or
0N/A * <code>readFully</code> method.
0N/A *
0N/A * @return an <code>int</code> containing the bit offset between
0N/A * 0 and 7, inclusive.
0N/A *
0N/A * @exception IOException if an I/O error occurs.
0N/A *
0N/A * @see #setBitOffset
0N/A */
0N/A int getBitOffset() throws IOException;
0N/A
0N/A /**
0N/A * Sets the bit offset to an integer between 0 and 7, inclusive.
0N/A * The byte offset within the stream, as returned by
0N/A * <code>getStreamPosition</code>, is left unchanged.
0N/A * A value of 0 indicates the
0N/A * most-significant bit, and a value of 7 indicates the least
0N/A * significant bit, of the byte being read.
0N/A *
0N/A * @param bitOffset the desired offset, as an <code>int</code>
0N/A * between 0 and 7, inclusive.
0N/A *
0N/A * @exception IllegalArgumentException if <code>bitOffset</code>
0N/A * is not between 0 and 7, inclusive.
0N/A * @exception IOException if an I/O error occurs.
0N/A *
0N/A * @see #getBitOffset
0N/A */
0N/A void setBitOffset(int bitOffset) throws IOException;
0N/A
0N/A /**
0N/A * Reads a single bit from the stream and returns it as an
0N/A * <code>int</code> with the value <code>0</code> or
0N/A * <code>1</code>. The bit offset is advanced by one and reduced
0N/A * modulo 8.
0N/A *
0N/A * @return an <code>int</code> containing the value <code>0</code>
0N/A * or <code>1</code>.
0N/A *
0N/A * @exception EOFException if the stream reaches the end before
0N/A * reading all the bits.
0N/A * @exception IOException if an I/O error occurs.
0N/A */
0N/A int readBit() throws IOException;
0N/A
0N/A /**
0N/A * Reads a bitstring from the stream and returns it as a
0N/A * <code>long</code>, with the first bit read becoming the most
0N/A * significant bit of the output. The read starts within the byte
0N/A * indicated by <code>getStreamPosition</code>, at the bit given
0N/A * by <code>getBitOffset</code>. The bit offset is advanced by
0N/A * <code>numBits</code> and reduced modulo 8.
0N/A *
0N/A * <p> The byte order of the stream has no effect on this
0N/A * method. The return value of this method is constructed as
0N/A * though the bits were read one at a time, and shifted into
0N/A * the right side of the return value, as shown by the following
0N/A * pseudo-code:
0N/A *
0N/A * <pre>
0N/A * long accum = 0L;
0N/A * for (int i = 0; i < numBits; i++) {
0N/A * accum <<= 1; // Shift left one bit to make room
0N/A * accum |= readBit();
0N/A * }
0N/A * </pre>
0N/A *
0N/A * Note that the result of <code>readBits(32)</code> may thus not
0N/A * be equal to that of <code>readInt()</code> if a reverse network
0N/A * byte order is being used (i.e., <code>getByteOrder() ==
0N/A * false</code>).
0N/A *
0N/A * <p> If the end of the stream is encountered before all the bits
0N/A * have been read, an <code>EOFException</code> is thrown.
0N/A *
0N/A * @param numBits the number of bits to read, as an <code>int</code>
0N/A * between 0 and 64, inclusive.
0N/A * @return the bitstring, as a <code>long</code> with the last bit
0N/A * read stored in the least significant bit.
0N/A *
0N/A * @exception IllegalArgumentException if <code>numBits</code>
0N/A * is not between 0 and 64, inclusive.
0N/A * @exception EOFException if the stream reaches the end before
0N/A * reading all the bits.
0N/A * @exception IOException if an I/O error occurs.
0N/A */
0N/A long readBits(int numBits) throws IOException;
0N/A
0N/A /**
0N/A * Returns the total length of the stream, if known. Otherwise,
0N/A * <code>-1</code> is returned.
0N/A *
0N/A * @return a <code>long</code> containing the length of the
0N/A * stream, if known, or else <code>-1</code>.
0N/A *
0N/A * @exception IOException if an I/O error occurs.
0N/A */
0N/A long length() throws IOException;
0N/A
0N/A /**
0N/A * Moves the stream position forward by a given number of bytes. It
0N/A * is possible that this method will only be able to skip forward
0N/A * by a smaller number of bytes than requested, for example if the
0N/A * end of the stream is reached. In all cases, the actual number
0N/A * of bytes skipped is returned. The bit offset is set to zero
0N/A * prior to advancing the position.
0N/A *
0N/A * @param n an <code>int</code> containing the number of bytes to
0N/A * be skipped.
0N/A *
0N/A * @return an <code>int</code> representing the number of bytes skipped.
0N/A *
0N/A * @exception IOException if an I/O error occurs.
0N/A */
0N/A int skipBytes(int n) throws IOException;
0N/A
0N/A /**
0N/A * Moves the stream position forward by a given number of bytes.
0N/A * This method is identical to <code>skipBytes(int)</code> except
0N/A * that it allows for a larger skip distance.
0N/A *
0N/A * @param n a <code>long</code> containing the number of bytes to
0N/A * be skipped.
0N/A *
0N/A * @return a <code>long</code> representing the number of bytes
0N/A * skipped.
0N/A *
0N/A * @exception IOException if an I/O error occurs.
0N/A */
0N/A long skipBytes(long n) throws IOException;
0N/A
0N/A /**
0N/A * Sets the current stream position to the desired location. The
0N/A * next read will occur at this location. The bit offset is set
0N/A * to 0.
0N/A *
0N/A * <p> An <code>IndexOutOfBoundsException</code> will be thrown if
0N/A * <code>pos</code> is smaller than the flushed position (as
0N/A * returned by <code>getflushedPosition</code>).
0N/A *
0N/A * <p> It is legal to seek past the end of the file; an
0N/A * <code>EOFException</code> will be thrown only if a read is
0N/A * performed.
0N/A *
0N/A * @param pos a <code>long</code> containing the desired file
0N/A * pointer position.
0N/A *
0N/A * @exception IndexOutOfBoundsException if <code>pos</code> is smaller
0N/A * than the flushed position.
0N/A * @exception IOException if any other I/O error occurs.
0N/A */
0N/A void seek(long pos) throws IOException;
0N/A
0N/A /**
0N/A * Marks a position in the stream to be returned to by a
0N/A * subsequent call to <code>reset</code>. Unlike a standard
0N/A * <code>InputStream</code>, all <code>ImageInputStream</code>s
0N/A * support marking. Additionally, calls to <code>mark</code> and
0N/A * <code>reset</code> may be nested arbitrarily.
0N/A *
0N/A * <p> Unlike the <code>mark</code> methods declared by the
0N/A * <code>Reader</code> and <code>InputStream</code> interfaces, no
0N/A * <code>readLimit</code> parameter is used. An arbitrary amount
0N/A * of data may be read following the call to <code>mark</code>.
0N/A *
0N/A * <p> The bit position used by the <code>readBits</code> method
0N/A * is saved and restored by each pair of calls to
0N/A * <code>mark</code> and <code>reset</code>.
0N/A *
0N/A * <p> Note that it is valid for an <code>ImageReader</code> to call
0N/A * <code>flushBefore</code> as part of a read operation.
0N/A * Therefore, if an application calls <code>mark</code> prior to
0N/A * passing that stream to an <code>ImageReader</code>, the application
0N/A * should not assume that the marked position will remain valid after
0N/A * the read operation has completed.
0N/A */
0N/A void mark();
0N/A
0N/A /**
0N/A * Returns the stream pointer to its previous position, including
0N/A * the bit offset, at the time of the most recent unmatched call
0N/A * to <code>mark</code>.
0N/A *
0N/A * <p> Calls to <code>reset</code> without a corresponding call
0N/A * to <code>mark</code> have no effect.
0N/A *
0N/A * <p> An <code>IOException</code> will be thrown if the previous
0N/A * marked position lies in the discarded portion of the stream.
0N/A *
0N/A * @exception IOException if an I/O error occurs.
0N/A */
0N/A void reset() throws IOException;
0N/A
0N/A /**
0N/A * Discards the initial portion of the stream prior to the
0N/A * indicated postion. Attempting to seek to an offset within the
0N/A * flushed portion of the stream will result in an
0N/A * <code>IndexOutOfBoundsException</code>.
0N/A *
0N/A * <p> Calling <code>flushBefore</code> may allow classes
0N/A * implementing this interface to free up resources such as memory
0N/A * or disk space that are being used to store data from the
0N/A * stream.
0N/A *
0N/A * @param pos a <code>long</code> containing the length of the
0N/A * stream prefix that may be flushed.
0N/A *
0N/A * @exception IndexOutOfBoundsException if <code>pos</code> lies
0N/A * in the flushed portion of the stream or past the current stream
0N/A * position.
0N/A * @exception IOException if an I/O error occurs.
0N/A */
0N/A void flushBefore(long pos) throws IOException;
0N/A
0N/A /**
0N/A * Discards the initial position of the stream prior to the current
0N/A * stream position. Equivalent to
0N/A * <code>flushBefore(getStreamPosition())</code>.
0N/A *
0N/A * @exception IOException if an I/O error occurs.
0N/A */
0N/A void flush() throws IOException;
0N/A
0N/A /**
0N/A * Returns the earliest position in the stream to which seeking
0N/A * may be performed. The returned value will be the maximum of
0N/A * all values passed into previous calls to
0N/A * <code>flushBefore</code>.
0N/A *
0N/A * @return the earliest legal position for seeking, as a
0N/A * <code>long</code>.
0N/A */
0N/A long getFlushedPosition();
0N/A
0N/A /**
0N/A * Returns <code>true</code> if this <code>ImageInputStream</code>
0N/A * caches data itself in order to allow seeking backwards.
0N/A * Applications may consult this in order to decide how frequently,
0N/A * or whether, to flush in order to conserve cache resources.
0N/A *
0N/A * @return <code>true</code> if this <code>ImageInputStream</code>
0N/A * caches data.
0N/A *
0N/A * @see #isCachedMemory
0N/A * @see #isCachedFile
0N/A */
0N/A boolean isCached();
0N/A
0N/A /**
0N/A * Returns <code>true</code> if this <code>ImageInputStream</code>
0N/A * caches data itself in order to allow seeking backwards, and
0N/A * the cache is kept in main memory. Applications may consult
0N/A * this in order to decide how frequently, or whether, to flush
0N/A * in order to conserve cache resources.
0N/A *
0N/A * @return <code>true</code> if this <code>ImageInputStream</code>
0N/A * caches data in main memory.
0N/A *
0N/A * @see #isCached
0N/A * @see #isCachedFile
0N/A */
0N/A boolean isCachedMemory();
0N/A
0N/A /**
0N/A * Returns <code>true</code> if this <code>ImageInputStream</code>
0N/A * caches data itself in order to allow seeking backwards, and
0N/A * the cache is kept in a temporary file. Applications may consult
0N/A * this in order to decide how frequently, or whether, to flush
0N/A * in order to conserve cache resources.
0N/A *
0N/A * @return <code>true</code> if this <code>ImageInputStream</code>
0N/A * caches data in a temporary file.
0N/A *
0N/A * @see #isCached
0N/A * @see #isCachedMemory
0N/A */
0N/A boolean isCachedFile();
0N/A
0N/A /**
0N/A * Closes the stream. Attempts to access a stream that has been
0N/A * closed may result in <code>IOException</code>s or incorrect
0N/A * behavior. Calling this method may allow classes implementing
0N/A * this interface to release resources associated with the stream
0N/A * such as memory, disk space, or file descriptors.
0N/A *
0N/A * @exception IOException if an I/O error occurs.
0N/A */
0N/A void close() throws IOException;
0N/A}