jdk/src/share/classes/java/io/SequenceInputStream.java
author igerasim
Thu, 13 Mar 2014 07:52:17 +0400
changeset 23344 70f819173479
parent 14342 8435a30053c1
child 24865 09b1d992ca72
permissions -rw-r--r--
7011804: SequenceInputStream with lots of empty substreams can cause StackOverflowError Reviewed-by: chegar, alanb
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: 11117
diff changeset
     2
 * Copyright (c) 1994, 2011, 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
import java.io.InputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.util.Enumeration;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.util.Vector;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * A <code>SequenceInputStream</code> represents
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * the logical concatenation of other input
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * streams. It starts out with an ordered
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * collection of input streams and reads from
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * the first one until end of file is reached,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * whereupon it reads from the second one,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * and so on, until end of file is reached
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * on the last of the contained input streams.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * @author  Author van Hoff
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * @since   JDK1.0
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 SequenceInputStream extends InputStream {
11117
b6e68b1344d4 7116404: Miscellaneous warnings (java.rmi.**, serialization, some core classes)
alanb
parents: 5506
diff changeset
    47
    Enumeration<? extends InputStream> e;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    InputStream in;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
     * Initializes a newly created <code>SequenceInputStream</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
     * by remembering the argument, which must
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
     * be an <code>Enumeration</code>  that produces
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
     * objects whose run-time type is <code>InputStream</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
     * The input streams that are  produced by
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
     * the enumeration will be read, in order,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
     * to provide the bytes to be read  from this
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
     * <code>SequenceInputStream</code>. After
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
     * each input stream from the enumeration
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     * is exhausted, it is closed by calling its
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
     * <code>close</code> method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     * @param   e   an enumeration of input streams.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     * @see     java.util.Enumeration
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    public SequenceInputStream(Enumeration<? extends InputStream> e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
        this.e = e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
            nextStream();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
        } catch (IOException ex) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
            // This should never happen
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
            throw new Error("panic");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * Initializes a newly
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * created <code>SequenceInputStream</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     * by remembering the two arguments, which
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     * will be read in order, first <code>s1</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * and then <code>s2</code>, to provide the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * bytes to be read from this <code>SequenceInputStream</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * @param   s1   the first input stream to read.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * @param   s2   the second input stream to read.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    public SequenceInputStream(InputStream s1, InputStream s2) {
11117
b6e68b1344d4 7116404: Miscellaneous warnings (java.rmi.**, serialization, some core classes)
alanb
parents: 5506
diff changeset
    88
        Vector<InputStream> v = new Vector<>(2);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        v.addElement(s1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        v.addElement(s2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        e = v.elements();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
            nextStream();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        } catch (IOException ex) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
            // This should never happen
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
            throw new Error("panic");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     *  Continues reading in the next stream if an EOF is reached.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    final void nextStream() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        if (in != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
            in.close();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        if (e.hasMoreElements()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
            in = (InputStream) e.nextElement();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
            if (in == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
                throw new NullPointerException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        else in = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     * Returns an estimate of the number of bytes that can be read (or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     * skipped over) from the current underlying input stream without
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * blocking by the next invocation of a method for the current
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * underlying input stream. The next invocation might be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     * the same thread or another thread.  A single read or skip of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * many bytes will not block, but may read or skip fewer bytes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * This method simply calls {@code available} of the current underlying
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * input stream and returns the result.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * @return an estimate of the number of bytes that can be read (or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     *         skipped over) from the current underlying input stream
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     *         without blocking or {@code 0} if this input stream
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     *         has been closed by invoking its {@link #close()} method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     * @exception  IOException  if an I/O error occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * @since   JDK1.1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    public int available() throws IOException {
23344
70f819173479 7011804: SequenceInputStream with lots of empty substreams can cause StackOverflowError
igerasim
parents: 14342
diff changeset
   138
        if (in == null) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
            return 0; // no way to signal EOF from available()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        return in.available();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * Reads the next byte of data from this input stream. The byte is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * returned as an <code>int</code> in the range <code>0</code> to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * <code>255</code>. If no byte is available because the end of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * stream has been reached, the value <code>-1</code> is returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * This method blocks until input data is available, the end of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     * stream is detected, or an exception is thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * This method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * tries to read one character from the current substream. If it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * reaches the end of the stream, it calls the <code>close</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     * method of the current substream and begins reading from the next
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     * substream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     * @return     the next byte of data, or <code>-1</code> if the end of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     *             stream is reached.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * @exception  IOException  if an I/O error occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    public int read() throws IOException {
23344
70f819173479 7011804: SequenceInputStream with lots of empty substreams can cause StackOverflowError
igerasim
parents: 14342
diff changeset
   163
        while (in != null) {
70f819173479 7011804: SequenceInputStream with lots of empty substreams can cause StackOverflowError
igerasim
parents: 14342
diff changeset
   164
            int c = in.read();
70f819173479 7011804: SequenceInputStream with lots of empty substreams can cause StackOverflowError
igerasim
parents: 14342
diff changeset
   165
            if (c != -1) {
70f819173479 7011804: SequenceInputStream with lots of empty substreams can cause StackOverflowError
igerasim
parents: 14342
diff changeset
   166
                return c;
70f819173479 7011804: SequenceInputStream with lots of empty substreams can cause StackOverflowError
igerasim
parents: 14342
diff changeset
   167
            }
70f819173479 7011804: SequenceInputStream with lots of empty substreams can cause StackOverflowError
igerasim
parents: 14342
diff changeset
   168
            nextStream();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        }
23344
70f819173479 7011804: SequenceInputStream with lots of empty substreams can cause StackOverflowError
igerasim
parents: 14342
diff changeset
   170
        return -1;
2
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
     * Reads up to <code>len</code> bytes of data from this input stream
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     * into an array of bytes.  If <code>len</code> is not zero, the method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     * blocks until at least 1 byte of input is available; otherwise, no
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     * bytes are read and <code>0</code> is returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     * The <code>read</code> method of <code>SequenceInputStream</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     * tries to read the data from the current substream. If it fails to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     * read any characters because the substream has reached the end of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     * the stream, it calls the <code>close</code> method of the current
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * substream and begins reading from the next substream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * @param      b     the buffer into which the data is read.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * @param      off   the start offset in array <code>b</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     *                   at which the data is written.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * @param      len   the maximum number of bytes read.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     * @return     int   the number of bytes read.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     * @exception  NullPointerException If <code>b</code> is <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     * @exception  IndexOutOfBoundsException If <code>off</code> is negative,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     * <code>len</code> is negative, or <code>len</code> is greater than
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     * <code>b.length - off</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     * @exception  IOException  if an I/O error occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
    public int read(byte b[], int off, int len) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
        if (in == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
            return -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        } else if (b == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
            throw new NullPointerException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        } else if (off < 0 || len < 0 || len > b.length - off) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
            throw new IndexOutOfBoundsException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        } else if (len == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
            return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
        }
23344
70f819173479 7011804: SequenceInputStream with lots of empty substreams can cause StackOverflowError
igerasim
parents: 14342
diff changeset
   206
        do {
70f819173479 7011804: SequenceInputStream with lots of empty substreams can cause StackOverflowError
igerasim
parents: 14342
diff changeset
   207
            int n = in.read(b, off, len);
70f819173479 7011804: SequenceInputStream with lots of empty substreams can cause StackOverflowError
igerasim
parents: 14342
diff changeset
   208
            if (n > 0) {
70f819173479 7011804: SequenceInputStream with lots of empty substreams can cause StackOverflowError
igerasim
parents: 14342
diff changeset
   209
                return n;
70f819173479 7011804: SequenceInputStream with lots of empty substreams can cause StackOverflowError
igerasim
parents: 14342
diff changeset
   210
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
            nextStream();
23344
70f819173479 7011804: SequenceInputStream with lots of empty substreams can cause StackOverflowError
igerasim
parents: 14342
diff changeset
   212
        } while (in != null);
70f819173479 7011804: SequenceInputStream with lots of empty substreams can cause StackOverflowError
igerasim
parents: 14342
diff changeset
   213
        return -1;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     * Closes this input stream and releases any system resources
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     * associated with the stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     * A closed <code>SequenceInputStream</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     * cannot  perform input operations and cannot
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     * be reopened.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     * If this stream was created
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     * from an enumeration, all remaining elements
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     * are requested from the enumeration and closed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     * before the <code>close</code> method returns.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     * @exception  IOException  if an I/O error occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    public void close() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        do {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
            nextStream();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        } while (in != null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
}