1 /*
2 * Copyright (c) 1994, 2019, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
42 * @author Jonathan Payne
43 * @since 1.0
44 */
45 public
46 class FilterInputStream extends InputStream {
47 /**
48 * The input stream to be filtered.
49 */
50 protected volatile InputStream in;
51
52 /**
53 * Creates a <code>FilterInputStream</code>
54 * by assigning the argument <code>in</code>
55 * to the field <code>this.in</code> so as
56 * to remember it for later use.
57 *
58 * @param in the underlying input stream, or <code>null</code> if
59 * this instance is to be created without an underlying stream.
60 */
61 protected FilterInputStream(InputStream in) {
62 if (in == null) {
63 throw new NullPointerException();
64 }
65 this.in = in;
66 }
67
68 /**
69 * Reads the next byte of data from this input stream. The value
70 * byte is returned as an <code>int</code> in the range
71 * <code>0</code> to <code>255</code>. If no byte is available
72 * because the end of the stream has been reached, the value
73 * <code>-1</code> is returned. This method blocks until input data
74 * is available, the end of the stream is detected, or an exception
75 * is thrown.
76 * <p>
77 * This method
78 * simply performs <code>in.read()</code> and returns the result.
79 *
80 * @return the next byte of data, or <code>-1</code> if the end of the
81 * stream is reached.
82 * @exception IOException if an I/O error occurs.
83 * @see java.io.FilterInputStream#in
84 */
|
1 /*
2 * Copyright (c) 1994, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
42 * @author Jonathan Payne
43 * @since 1.0
44 */
45 public
46 class FilterInputStream extends InputStream {
47 /**
48 * The input stream to be filtered.
49 */
50 protected volatile InputStream in;
51
52 /**
53 * Creates a <code>FilterInputStream</code>
54 * by assigning the argument <code>in</code>
55 * to the field <code>this.in</code> so as
56 * to remember it for later use.
57 *
58 * @param in the underlying input stream, or <code>null</code> if
59 * this instance is to be created without an underlying stream.
60 */
61 protected FilterInputStream(InputStream in) {
62 this.in = in;
63 }
64
65 /**
66 * Reads the next byte of data from this input stream. The value
67 * byte is returned as an <code>int</code> in the range
68 * <code>0</code> to <code>255</code>. If no byte is available
69 * because the end of the stream has been reached, the value
70 * <code>-1</code> is returned. This method blocks until input data
71 * is available, the end of the stream is detected, or an exception
72 * is thrown.
73 * <p>
74 * This method
75 * simply performs <code>in.read()</code> and returns the result.
76 *
77 * @return the next byte of data, or <code>-1</code> if the end of the
78 * stream is reached.
79 * @exception IOException if an I/O error occurs.
80 * @see java.io.FilterInputStream#in
81 */
|