Moving modules around so the runtime is under one master pom and can be built without building other modules that are in the repository
2 * Copyright (c) 1994, 2011, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
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.
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).
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.
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
29 * This class is the superclass of all classes that filter output
30 * streams. These streams sit on top of an already existing output
31 * stream (the <i>underlying</i> output stream) which it uses as its
32 * basic sink of data, but possibly transforming the data along the
33 * way or providing additional functionality.
35 * The class <code>FilterOutputStream</code> itself simply overrides
36 * all methods of <code>OutputStream</code> with versions that pass
37 * all requests to the underlying output stream. Subclasses of
38 * <code>FilterOutputStream</code> may further override some of these
39 * methods as well as provide additional methods and fields.
41 * @author Jonathan Payne
45 class FilterOutputStream extends OutputStream {
47 * The underlying output stream to be filtered.
49 protected OutputStream out;
52 * Creates an output stream filter built on top of the specified
53 * underlying output stream.
55 * @param out the underlying output stream to be assigned to
56 * the field <tt>this.out</tt> for later use, or
57 * <code>null</code> if this instance is to be
58 * created without an underlying stream.
60 public FilterOutputStream(OutputStream out) {
65 * Writes the specified <code>byte</code> to this output stream.
67 * The <code>write</code> method of <code>FilterOutputStream</code>
68 * calls the <code>write</code> method of its underlying output stream,
69 * that is, it performs <tt>out.write(b)</tt>.
71 * Implements the abstract <tt>write</tt> method of <tt>OutputStream</tt>.
73 * @param b the <code>byte</code>.
74 * @exception IOException if an I/O error occurs.
76 public void write(int b) throws IOException {
81 * Writes <code>b.length</code> bytes to this output stream.
83 * The <code>write</code> method of <code>FilterOutputStream</code>
84 * calls its <code>write</code> method of three arguments with the
85 * arguments <code>b</code>, <code>0</code>, and
86 * <code>b.length</code>.
88 * Note that this method does not call the one-argument
89 * <code>write</code> method of its underlying stream with the single
90 * argument <code>b</code>.
92 * @param b the data to be written.
93 * @exception IOException if an I/O error occurs.
94 * @see java.io.FilterOutputStream#write(byte[], int, int)
96 public void write(byte b[]) throws IOException {
97 write(b, 0, b.length);
101 * Writes <code>len</code> bytes from the specified
102 * <code>byte</code> array starting at offset <code>off</code> to
103 * this output stream.
105 * The <code>write</code> method of <code>FilterOutputStream</code>
106 * calls the <code>write</code> method of one argument on each
107 * <code>byte</code> to output.
109 * Note that this method does not call the <code>write</code> method
110 * of its underlying input stream with the same arguments. Subclasses
111 * of <code>FilterOutputStream</code> should provide a more efficient
112 * implementation of this method.
115 * @param off the start offset in the data.
116 * @param len the number of bytes to write.
117 * @exception IOException if an I/O error occurs.
118 * @see java.io.FilterOutputStream#write(int)
120 public void write(byte b[], int off, int len) throws IOException {
121 if ((off | len | (b.length - (len + off)) | (off + len)) < 0)
122 throw new IndexOutOfBoundsException();
124 for (int i = 0 ; i < len ; i++) {
130 * Flushes this output stream and forces any buffered output bytes
131 * to be written out to the stream.
133 * The <code>flush</code> method of <code>FilterOutputStream</code>
134 * calls the <code>flush</code> method of its underlying output stream.
136 * @exception IOException if an I/O error occurs.
137 * @see java.io.FilterOutputStream#out
139 public void flush() throws IOException {
144 * Closes this output stream and releases any system resources
145 * associated with the stream.
147 * The <code>close</code> method of <code>FilterOutputStream</code>
148 * calls its <code>flush</code> method, and then calls the
149 * <code>close</code> method of its underlying output stream.
151 * @exception IOException if an I/O error occurs.
152 * @see java.io.FilterOutputStream#flush()
153 * @see java.io.FilterOutputStream#out
155 public void close() throws IOException {
158 } catch (IOException ignored) {