jdk/src/java.base/share/classes/java/io/Reader.java
author avstepan
Thu, 06 Aug 2015 13:20:13 +0300
changeset 32033 bf24e33c7919
parent 30443 8d2f2ce637bd
child 32649 2ee9017c7597
permissions -rw-r--r--
8132468: docs: replace <tt> tags (obsolete in html5) for java.io, java.lang, java.math Reviewed-by: lancea, dfuchs, smarks
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
14342
8435a30053c1 7197491: update copyright year to match last edit in jdk8 jdk repository
alanb
parents: 14014
diff changeset
     2
 * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package java.io;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 * Abstract class for reading character streams.  The only methods that a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * subclass must implement are read(char[], int, int) and close().  Most
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * subclasses, however, will override some of the methods defined here in order
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * to provide higher efficiency, additional functionality, or both.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * @see BufferedReader
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * @see   LineNumberReader
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * @see CharArrayReader
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * @see InputStreamReader
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * @see   FileReader
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * @see FilterReader
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * @see   PushbackReader
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * @see PipedReader
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * @see StringReader
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * @see Writer
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * @author      Mark Reinhold
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 14342
diff changeset
    48
 * @since       1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
public abstract class Reader implements Readable, Closeable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
     * The object used to synchronize operations on this stream.  For
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
     * efficiency, a character-stream object may use an object other than
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
     * itself to protect critical sections.  A subclass should therefore use
32033
bf24e33c7919 8132468: docs: replace <tt> tags (obsolete in html5) for java.io, java.lang, java.math
avstepan
parents: 30443
diff changeset
    57
     * the object in this field rather than {@code this} or a synchronized
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
     * method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    protected Object lock;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     * Creates a new character-stream reader whose critical sections will
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     * synchronize on the reader itself.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    protected Reader() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
        this.lock = this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     * Creates a new character-stream reader whose critical sections will
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * synchronize on the given object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     * @param lock  The Object to synchronize on.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    protected Reader(Object lock) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        if (lock == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
            throw new NullPointerException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        this.lock = lock;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * Attempts to read characters into the specified character buffer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * The buffer is used as a repository of characters as-is: the only
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     * changes made are the results of a put operation. No flipping or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * rewinding of the buffer is performed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     * @param target the buffer to read characters into
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     * @return The number of characters added to the buffer, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     *         -1 if this source of characters is at its end
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * @throws IOException if an I/O error occurs
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * @throws NullPointerException if target is null
14014
da3648e13e67 8000269: Cleanup javadoc warnings
alanb
parents: 5506
diff changeset
    94
     * @throws java.nio.ReadOnlyBufferException if target is a read only buffer
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    public int read(java.nio.CharBuffer target) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        int len = target.remaining();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        char[] cbuf = new char[len];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        int n = read(cbuf, 0, len);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        if (n > 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
            target.put(cbuf, 0, n);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        return n;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * Reads a single character.  This method will block until a character is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * available, an I/O error occurs, or the end of the stream is reached.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * <p> Subclasses that intend to support efficient single-character input
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * should override this method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * @return     The character read, as an integer in the range 0 to 65535
32033
bf24e33c7919 8132468: docs: replace <tt> tags (obsolete in html5) for java.io, java.lang, java.math
avstepan
parents: 30443
diff changeset
   114
     *             ({@code 0x00-0xffff}), or -1 if the end of the stream has
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     *             been reached
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * @exception  IOException  If an I/O error occurs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    public int read() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        char cb[] = new char[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        if (read(cb, 0, 1) == -1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
            return -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
            return cb[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * Reads characters into an array.  This method will block until some input
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * is available, an I/O error occurs, or the end of the stream is reached.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * @param       cbuf  Destination buffer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     * @return      The number of characters read, or -1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     *              if the end of the stream
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     *              has been reached
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     * @exception   IOException  If an I/O error occurs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    public int read(char cbuf[]) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        return read(cbuf, 0, cbuf.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     * Reads characters into a portion of an array.  This method will block
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * until some input is available, an I/O error occurs, or the end of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * stream is reached.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * @param      cbuf  Destination buffer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * @param      off   Offset at which to start storing characters
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     * @param      len   Maximum number of characters to read
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * @return     The number of characters read, or -1 if the end of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     *             stream has been reached
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     * @exception  IOException  If an I/O error occurs
30443
8d2f2ce637bd 8029689: (spec) Reader.read(char[], int, int) throws unspecified IndexOutOfBoundsException
prappo
parents: 25859
diff changeset
   156
     * @exception  IndexOutOfBoundsException
8d2f2ce637bd 8029689: (spec) Reader.read(char[], int, int) throws unspecified IndexOutOfBoundsException
prappo
parents: 25859
diff changeset
   157
     *             If {@code off} is negative, or {@code len} is negative,
8d2f2ce637bd 8029689: (spec) Reader.read(char[], int, int) throws unspecified IndexOutOfBoundsException
prappo
parents: 25859
diff changeset
   158
     *             or {@code len} is greater than {@code cbuf.length - off}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    abstract public int read(char cbuf[], int off, int len) throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    /** Maximum skip-buffer size */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    private static final int maxSkipBufferSize = 8192;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    /** Skip buffer, null until allocated */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    private char skipBuffer[] = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     * Skips characters.  This method will block until some characters are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     * available, an I/O error occurs, or the end of the stream is reached.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     * @param  n  The number of characters to skip
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     * @return    The number of characters actually skipped
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     * @exception  IllegalArgumentException  If <code>n</code> is negative.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     * @exception  IOException  If an I/O error occurs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    public long skip(long n) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        if (n < 0L)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
            throw new IllegalArgumentException("skip value is negative");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        int nn = (int) Math.min(n, maxSkipBufferSize);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        synchronized (lock) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
            if ((skipBuffer == null) || (skipBuffer.length < nn))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
                skipBuffer = new char[nn];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
            long r = n;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
            while (r > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
                int nc = read(skipBuffer, 0, (int)Math.min(r, nn));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
                if (nc == -1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
                r -= nc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
            return n - r;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     * Tells whether this stream is ready to be read.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     * @return True if the next read() is guaranteed not to block for input,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     * false otherwise.  Note that returning false does not guarantee that the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     * next read will block.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     * @exception  IOException  If an I/O error occurs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    public boolean ready() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     * Tells whether this stream supports the mark() operation. The default
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     * implementation always returns false. Subclasses should override this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     * method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     * @return true if and only if this stream supports the mark operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    public boolean markSupported() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     * Marks the present position in the stream.  Subsequent calls to reset()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     * will attempt to reposition the stream to this point.  Not all
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     * character-input streams support the mark() operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     * @param  readAheadLimit  Limit on the number of characters that may be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     *                         read while still preserving the mark.  After
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     *                         reading this many characters, attempting to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     *                         reset the stream may fail.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     * @exception  IOException  If the stream does not support mark(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
     *                          or if some other I/O error occurs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    public void mark(int readAheadLimit) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        throw new IOException("mark() not supported");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     * Resets the stream.  If the stream has been marked, then attempt to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     * reposition it at the mark.  If the stream has not been marked, then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     * attempt to reset it in some way appropriate to the particular stream,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     * for example by repositioning it to its starting point.  Not all
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     * character-input streams support the reset() operation, and some support
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     * reset() without supporting mark().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     * @exception  IOException  If the stream has not been marked,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
     *                          or if the mark has been invalidated,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
     *                          or if the stream does not support reset(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     *                          or if some other I/O error occurs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
    public void reset() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        throw new IOException("reset() not supported");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
     * Closes the stream and releases any system resources associated with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
     * it.  Once the stream has been closed, further read(), ready(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
     * mark(), reset(), or skip() invocations will throw an IOException.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     * Closing a previously closed stream has no effect.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     * @exception  IOException  If an I/O error occurs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     abstract public void close() throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
}