src/java.base/share/classes/java/io/FilterInputStream.java
author bpb
Wed, 17 Jul 2019 14:24:37 -0700
changeset 55728 978350939943
parent 47216 71c04702a3d5
child 55741 880266b6e5b3
permissions -rw-r--r--
8067801: Enforce null check for underlying I/O streams Reviewed-by: lancea
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
55728
978350939943 8067801: Enforce null check for underlying I/O streams
bpb
parents: 47216
diff changeset
     2
 * Copyright (c) 1994, 2019, 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: 5201
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: 5201
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: 5201
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 5201
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 5201
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
 * A <code>FilterInputStream</code> contains
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 * some other input stream, which it uses as
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * its  basic source of data, possibly transforming
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * the data along the way or providing  additional
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * functionality. The class <code>FilterInputStream</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * itself simply overrides all  methods of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * <code>InputStream</code> with versions that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * pass all requests to the contained  input
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * stream. Subclasses of <code>FilterInputStream</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * may further override some of  these methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * and may also provide additional methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * and fields.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * @author  Jonathan Payne
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 7668
diff changeset
    43
 * @since   1.0
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
public
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
class FilterInputStream extends InputStream {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
     * The input stream to be filtered.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    protected volatile InputStream in;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
     * Creates a <code>FilterInputStream</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
     * by assigning the  argument <code>in</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
     * to the field <code>this.in</code> so as
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
     * to remember it for later use.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
     * @param   in   the underlying input stream, or <code>null</code> if
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
     *          this instance is to be created without an underlying stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    protected FilterInputStream(InputStream in) {
55728
978350939943 8067801: Enforce null check for underlying I/O streams
bpb
parents: 47216
diff changeset
    62
        if (in == null) {
978350939943 8067801: Enforce null check for underlying I/O streams
bpb
parents: 47216
diff changeset
    63
            throw new NullPointerException();
978350939943 8067801: Enforce null check for underlying I/O streams
bpb
parents: 47216
diff changeset
    64
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        this.in = in;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     * Reads the next byte of data from this input stream. The value
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     * byte is returned as an <code>int</code> in the range
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     * <code>0</code> to <code>255</code>. If no byte is available
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * because the end of the stream has been reached, the value
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     * <code>-1</code> is returned. This method blocks until input data
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     * is available, the end of the stream is detected, or an exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     * is thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * This method
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * simply performs <code>in.read()</code> and returns the result.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     * @return     the next byte of data, or <code>-1</code> if the end of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     *             stream is reached.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * @exception  IOException  if an I/O error occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * @see        java.io.FilterInputStream#in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    public int read() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        return in.read();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    /**
43794
497288c158bf 8173094: Error in API documentation for SwingWorker
coffeys
parents: 39121
diff changeset
    90
     * Reads up to <code>b.length</code> bytes of data from this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     * input stream into an array of bytes. This method blocks until some
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * input is available.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * This method simply performs the call
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     * <code>read(b, 0, b.length)</code> and returns
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     * the  result. It is important that it does
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     * <i>not</i> do <code>in.read(b)</code> instead;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * certain subclasses of  <code>FilterInputStream</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * depend on the implementation strategy actually
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * @param      b   the buffer into which the data is read.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     * @return     the total number of bytes read into the buffer, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     *             <code>-1</code> if there is no more data because the end of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     *             the stream has been reached.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * @exception  IOException  if an I/O error occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * @see        java.io.FilterInputStream#read(byte[], int, int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    public int read(byte b[]) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        return read(b, 0, b.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * Reads up to <code>len</code> bytes of data from this input stream
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * into an array of bytes. If <code>len</code> is not zero, the method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     * blocks until some input is available; otherwise, no
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * bytes are read and <code>0</code> is returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     * This method simply performs <code>in.read(b, off, len)</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     * and returns the result.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * @param      b     the buffer into which the data is read.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     * @param      off   the start offset in the destination array <code>b</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * @param      len   the maximum number of bytes read.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     * @return     the total number of bytes read into the buffer, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     *             <code>-1</code> if there is no more data because the end of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     *             the stream has been reached.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * @exception  NullPointerException If <code>b</code> is <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * @exception  IndexOutOfBoundsException If <code>off</code> is negative,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * <code>len</code> is negative, or <code>len</code> is greater than
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * <code>b.length - off</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     * @exception  IOException  if an I/O error occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     * @see        java.io.FilterInputStream#in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    public int read(byte b[], int off, int len) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        return in.read(b, off, len);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    /**
5201
37e71048195f 6717164: FilterInputStream.skip incorrectly inherits wording specifying how the InputStream.skip works
sherman
parents: 2
diff changeset
   140
     * Skips over and discards <code>n</code> bytes of data from the
37e71048195f 6717164: FilterInputStream.skip incorrectly inherits wording specifying how the InputStream.skip works
sherman
parents: 2
diff changeset
   141
     * input stream. The <code>skip</code> method may, for a variety of
37e71048195f 6717164: FilterInputStream.skip incorrectly inherits wording specifying how the InputStream.skip works
sherman
parents: 2
diff changeset
   142
     * reasons, end up skipping over some smaller number of bytes,
37e71048195f 6717164: FilterInputStream.skip incorrectly inherits wording specifying how the InputStream.skip works
sherman
parents: 2
diff changeset
   143
     * possibly <code>0</code>. The actual number of bytes skipped is
37e71048195f 6717164: FilterInputStream.skip incorrectly inherits wording specifying how the InputStream.skip works
sherman
parents: 2
diff changeset
   144
     * returned.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * This method simply performs <code>in.skip(n)</code>.
5201
37e71048195f 6717164: FilterInputStream.skip incorrectly inherits wording specifying how the InputStream.skip works
sherman
parents: 2
diff changeset
   147
     *
37e71048195f 6717164: FilterInputStream.skip incorrectly inherits wording specifying how the InputStream.skip works
sherman
parents: 2
diff changeset
   148
     * @param      n   the number of bytes to be skipped.
37e71048195f 6717164: FilterInputStream.skip incorrectly inherits wording specifying how the InputStream.skip works
sherman
parents: 2
diff changeset
   149
     * @return     the actual number of bytes skipped.
39121
a1a92fce338a 8136738: InputStream documentation for IOException in skip() is unclear or incorrect
bpb
parents: 25859
diff changeset
   150
     * @throws     IOException  if {@code in.skip(n)} throws an IOException.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    public long skip(long n) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        return in.skip(n);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * Returns an estimate of the number of bytes that can be read (or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     * skipped over) from this input stream without blocking by the next
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * caller of a method for this input stream. The next caller might be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * the same thread or another thread.  A single read or skip of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * many bytes will not block, but may read or skip fewer bytes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     * This method returns the result of {@link #in in}.available().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     * @return     an estimate of the number of bytes that can be read (or skipped
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     *             over) from this input stream without blocking.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     * @exception  IOException  if an I/O error occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    public int available() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
        return in.available();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     * Closes this input stream and releases any system resources
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     * associated with the stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     * This
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     * method simply performs <code>in.close()</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     * @exception  IOException  if an I/O error occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     * @see        java.io.FilterInputStream#in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
    public void close() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        in.close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * Marks the current position in this input stream. A subsequent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * call to the <code>reset</code> method repositions this stream at
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     * the last marked position so that subsequent reads re-read the same bytes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     * The <code>readlimit</code> argument tells this input stream to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     * allow that many bytes to be read before the mark position gets
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     * invalidated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     * This method simply performs <code>in.mark(readlimit)</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     * @param   readlimit   the maximum limit of bytes that can be read before
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     *                      the mark position becomes invalid.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     * @see     java.io.FilterInputStream#in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     * @see     java.io.FilterInputStream#reset()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
    public synchronized void mark(int readlimit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        in.mark(readlimit);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     * Repositions this stream to the position at the time the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     * <code>mark</code> method was last called on this input stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     * This method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     * simply performs <code>in.reset()</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     * Stream marks are intended to be used in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     * situations where you need to read ahead a little to see what's in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     * the stream. Often this is most easily done by invoking some
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     * general parser. If the stream is of the type handled by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     * parse, it just chugs along happily. If the stream is not of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     * that type, the parser should toss an exception when it fails.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     * If this happens within readlimit bytes, it allows the outer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     * code to reset the stream and try another parser.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     * @exception  IOException  if the stream has not been marked or if the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     *               mark has been invalidated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     * @see        java.io.FilterInputStream#in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     * @see        java.io.FilterInputStream#mark(int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
    public synchronized void reset() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        in.reset();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
     * Tests if this input stream supports the <code>mark</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
     * and <code>reset</code> methods.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
     * This method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
     * simply performs <code>in.markSupported()</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     * @return  <code>true</code> if this stream type supports the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     *          <code>mark</code> and <code>reset</code> method;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     *          <code>false</code> otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     * @see     java.io.FilterInputStream#in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     * @see     java.io.InputStream#mark(int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     * @see     java.io.InputStream#reset()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
    public boolean markSupported() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        return in.markSupported();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
}