src/java.base/share/classes/java/io/OutputStream.java
author chegar
Thu, 17 Oct 2019 20:54:25 +0100
branchdatagramsocketimpl-branch
changeset 58679 9c3209ff7550
parent 58678 9cf78a70fa4f
parent 58288 48e480e56aad
permissions -rw-r--r--
datagramsocketimpl-branch: merge with default
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
58054
ee230ad8cfef 8230723: Remove default constructors from java.lang and java.io
darcy
parents: 48461
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: 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
47920
52c9e8d2f8d9 8191516: OutputStream.write(byte[],int,int) could have fewer parameter bounds checks
bpb
parents: 47216
diff changeset
    28
import java.util.Objects;
52c9e8d2f8d9 8191516: OutputStream.write(byte[],int,int) could have fewer parameter bounds checks
bpb
parents: 47216
diff changeset
    29
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * This abstract class is the superclass of all classes representing
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * an output stream of bytes. An output stream accepts output bytes
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * and sends them to some sink.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * Applications that need to define a subclass of
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
    36
 * {@code OutputStream} must always provide at least a method
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * that writes one byte of output.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * @author  Arthur van Hoff
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * @see     java.io.BufferedOutputStream
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * @see     java.io.ByteArrayOutputStream
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * @see     java.io.DataOutputStream
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * @see     java.io.FilterOutputStream
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * @see     java.io.InputStream
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * @see     java.io.OutputStream#write(int)
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 5506
diff changeset
    46
 * @since   1.0
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
public abstract class OutputStream implements Closeable, Flushable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    /**
58054
ee230ad8cfef 8230723: Remove default constructors from java.lang and java.io
darcy
parents: 48461
diff changeset
    50
     * Constructor for subclasses to call.
ee230ad8cfef 8230723: Remove default constructors from java.lang and java.io
darcy
parents: 48461
diff changeset
    51
     */
ee230ad8cfef 8230723: Remove default constructors from java.lang and java.io
darcy
parents: 48461
diff changeset
    52
    public OutputStream() {}
ee230ad8cfef 8230723: Remove default constructors from java.lang and java.io
darcy
parents: 48461
diff changeset
    53
ee230ad8cfef 8230723: Remove default constructors from java.lang and java.io
darcy
parents: 48461
diff changeset
    54
    /**
48461
6a1c3a5e04f3 4358774: Add null InputStream and OutputStream
bpb
parents: 47920
diff changeset
    55
     * Returns a new {@code OutputStream} which discards all bytes.  The
6a1c3a5e04f3 4358774: Add null InputStream and OutputStream
bpb
parents: 47920
diff changeset
    56
     * returned stream is initially open.  The stream is closed by calling
6a1c3a5e04f3 4358774: Add null InputStream and OutputStream
bpb
parents: 47920
diff changeset
    57
     * the {@code close()} method.  Subsequent calls to {@code close()} have
6a1c3a5e04f3 4358774: Add null InputStream and OutputStream
bpb
parents: 47920
diff changeset
    58
     * no effect.
6a1c3a5e04f3 4358774: Add null InputStream and OutputStream
bpb
parents: 47920
diff changeset
    59
     *
6a1c3a5e04f3 4358774: Add null InputStream and OutputStream
bpb
parents: 47920
diff changeset
    60
     * <p> While the stream is open, the {@code write(int)}, {@code
6a1c3a5e04f3 4358774: Add null InputStream and OutputStream
bpb
parents: 47920
diff changeset
    61
     * write(byte[])}, and {@code write(byte[], int, int)} methods do nothing.
6a1c3a5e04f3 4358774: Add null InputStream and OutputStream
bpb
parents: 47920
diff changeset
    62
     * After the stream has been closed, these methods all throw {@code
6a1c3a5e04f3 4358774: Add null InputStream and OutputStream
bpb
parents: 47920
diff changeset
    63
     * IOException}.
6a1c3a5e04f3 4358774: Add null InputStream and OutputStream
bpb
parents: 47920
diff changeset
    64
     *
6a1c3a5e04f3 4358774: Add null InputStream and OutputStream
bpb
parents: 47920
diff changeset
    65
     * <p> The {@code flush()} method does nothing.
6a1c3a5e04f3 4358774: Add null InputStream and OutputStream
bpb
parents: 47920
diff changeset
    66
     *
6a1c3a5e04f3 4358774: Add null InputStream and OutputStream
bpb
parents: 47920
diff changeset
    67
     * @return an {@code OutputStream} which discards all bytes
6a1c3a5e04f3 4358774: Add null InputStream and OutputStream
bpb
parents: 47920
diff changeset
    68
     *
6a1c3a5e04f3 4358774: Add null InputStream and OutputStream
bpb
parents: 47920
diff changeset
    69
     * @since 11
6a1c3a5e04f3 4358774: Add null InputStream and OutputStream
bpb
parents: 47920
diff changeset
    70
     */
6a1c3a5e04f3 4358774: Add null InputStream and OutputStream
bpb
parents: 47920
diff changeset
    71
    public static OutputStream nullOutputStream() {
6a1c3a5e04f3 4358774: Add null InputStream and OutputStream
bpb
parents: 47920
diff changeset
    72
        return new OutputStream() {
6a1c3a5e04f3 4358774: Add null InputStream and OutputStream
bpb
parents: 47920
diff changeset
    73
            private volatile boolean closed;
6a1c3a5e04f3 4358774: Add null InputStream and OutputStream
bpb
parents: 47920
diff changeset
    74
6a1c3a5e04f3 4358774: Add null InputStream and OutputStream
bpb
parents: 47920
diff changeset
    75
            private void ensureOpen() throws IOException {
6a1c3a5e04f3 4358774: Add null InputStream and OutputStream
bpb
parents: 47920
diff changeset
    76
                if (closed) {
6a1c3a5e04f3 4358774: Add null InputStream and OutputStream
bpb
parents: 47920
diff changeset
    77
                    throw new IOException("Stream closed");
6a1c3a5e04f3 4358774: Add null InputStream and OutputStream
bpb
parents: 47920
diff changeset
    78
                }
6a1c3a5e04f3 4358774: Add null InputStream and OutputStream
bpb
parents: 47920
diff changeset
    79
            }
6a1c3a5e04f3 4358774: Add null InputStream and OutputStream
bpb
parents: 47920
diff changeset
    80
6a1c3a5e04f3 4358774: Add null InputStream and OutputStream
bpb
parents: 47920
diff changeset
    81
            @Override
6a1c3a5e04f3 4358774: Add null InputStream and OutputStream
bpb
parents: 47920
diff changeset
    82
            public void write(int b) throws IOException {
6a1c3a5e04f3 4358774: Add null InputStream and OutputStream
bpb
parents: 47920
diff changeset
    83
                ensureOpen();
6a1c3a5e04f3 4358774: Add null InputStream and OutputStream
bpb
parents: 47920
diff changeset
    84
            }
6a1c3a5e04f3 4358774: Add null InputStream and OutputStream
bpb
parents: 47920
diff changeset
    85
6a1c3a5e04f3 4358774: Add null InputStream and OutputStream
bpb
parents: 47920
diff changeset
    86
            @Override
6a1c3a5e04f3 4358774: Add null InputStream and OutputStream
bpb
parents: 47920
diff changeset
    87
            public void write(byte b[], int off, int len) throws IOException {
6a1c3a5e04f3 4358774: Add null InputStream and OutputStream
bpb
parents: 47920
diff changeset
    88
                Objects.checkFromIndexSize(off, len, b.length);
6a1c3a5e04f3 4358774: Add null InputStream and OutputStream
bpb
parents: 47920
diff changeset
    89
                ensureOpen();
6a1c3a5e04f3 4358774: Add null InputStream and OutputStream
bpb
parents: 47920
diff changeset
    90
            }
6a1c3a5e04f3 4358774: Add null InputStream and OutputStream
bpb
parents: 47920
diff changeset
    91
6a1c3a5e04f3 4358774: Add null InputStream and OutputStream
bpb
parents: 47920
diff changeset
    92
            @Override
6a1c3a5e04f3 4358774: Add null InputStream and OutputStream
bpb
parents: 47920
diff changeset
    93
            public void close() {
6a1c3a5e04f3 4358774: Add null InputStream and OutputStream
bpb
parents: 47920
diff changeset
    94
                closed = true;
6a1c3a5e04f3 4358774: Add null InputStream and OutputStream
bpb
parents: 47920
diff changeset
    95
            }
6a1c3a5e04f3 4358774: Add null InputStream and OutputStream
bpb
parents: 47920
diff changeset
    96
        };
6a1c3a5e04f3 4358774: Add null InputStream and OutputStream
bpb
parents: 47920
diff changeset
    97
    }
6a1c3a5e04f3 4358774: Add null InputStream and OutputStream
bpb
parents: 47920
diff changeset
    98
6a1c3a5e04f3 4358774: Add null InputStream and OutputStream
bpb
parents: 47920
diff changeset
    99
    /**
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * Writes the specified byte to this output stream. The general
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   101
     * contract for {@code write} is that one byte is written
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * to the output stream. The byte to be written is the eight
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   103
     * low-order bits of the argument {@code b}. The 24
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   104
     * high-order bits of {@code b} are ignored.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * <p>
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   106
     * Subclasses of {@code OutputStream} must provide an
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * implementation for this method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     *
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   109
     * @param      b   the {@code byte}.
58242
94bb65cb37d3 8230648: Replace @exception tag with @throws in java.base
jboes
parents: 58054
diff changeset
   110
     * @throws     IOException  if an I/O error occurs. In particular,
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   111
     *             an {@code IOException} may be thrown if the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     *             output stream has been closed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    public abstract void write(int b) throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    /**
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   117
     * Writes {@code b.length} bytes from the specified byte array
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   118
     * to this output stream. The general contract for {@code write(b)}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     * is that it should have exactly the same effect as the call
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   120
     * {@code write(b, 0, b.length)}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * @param      b   the data.
58242
94bb65cb37d3 8230648: Replace @exception tag with @throws in java.base
jboes
parents: 58054
diff changeset
   123
     * @throws     IOException  if an I/O error occurs.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * @see        java.io.OutputStream#write(byte[], int, int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    public void write(byte b[]) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        write(b, 0, b.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    /**
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   131
     * Writes {@code len} bytes from the specified byte array
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   132
     * starting at offset {@code off} to this output stream.
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   133
     * The general contract for {@code write(b, off, len)} is that
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   134
     * some of the bytes in the array {@code b} are written to the
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   135
     * output stream in order; element {@code b[off]} is the first
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   136
     * byte written and {@code b[off+len-1]} is the last byte written
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     * by this operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * <p>
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   139
     * The {@code write} method of {@code OutputStream} calls
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     * the write method of one argument on each of the bytes to be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     * written out. Subclasses are encouraged to override this method and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     * provide a more efficient implementation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     * <p>
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   144
     * If {@code b} is {@code null}, a
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   145
     * {@code NullPointerException} is thrown.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * <p>
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   147
     * If {@code off} is negative, or {@code len} is negative, or
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   148
     * {@code off+len} is greater than the length of the array
32033
bf24e33c7919 8132468: docs: replace <tt> tags (obsolete in html5) for java.io, java.lang, java.math
avstepan
parents: 25859
diff changeset
   149
     * {@code b}, then an {@code IndexOutOfBoundsException} is thrown.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     * @param      b     the data.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * @param      off   the start offset in the data.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * @param      len   the number of bytes to write.
58242
94bb65cb37d3 8230648: Replace @exception tag with @throws in java.base
jboes
parents: 58054
diff changeset
   154
     * @throws     IOException  if an I/O error occurs. In particular,
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   155
     *             an {@code IOException} is thrown if the output
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     *             stream is closed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    public void write(byte b[], int off, int len) throws IOException {
47920
52c9e8d2f8d9 8191516: OutputStream.write(byte[],int,int) could have fewer parameter bounds checks
bpb
parents: 47216
diff changeset
   159
        Objects.checkFromIndexSize(off, len, b.length);
52c9e8d2f8d9 8191516: OutputStream.write(byte[],int,int) could have fewer parameter bounds checks
bpb
parents: 47216
diff changeset
   160
        // len == 0 condition implicitly handled by loop bounds
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        for (int i = 0 ; i < len ; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
            write(b[off + i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     * Flushes this output stream and forces any buffered output bytes
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   168
     * to be written out. The general contract of {@code flush} is
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     * that calling it is an indication that, if any bytes previously
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     * written have been buffered by the implementation of the output
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     * stream, such bytes should immediately be written to their
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     * intended destination.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     * If the intended destination of this stream is an abstraction provided by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     * the underlying operating system, for example a file, then flushing the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     * stream guarantees only that bytes previously written to the stream are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     * passed to the operating system for writing; it does not guarantee that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * they are actually written to a physical device such as a disk drive.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     * <p>
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   180
     * The {@code flush} method of {@code OutputStream} does nothing.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     *
58242
94bb65cb37d3 8230648: Replace @exception tag with @throws in java.base
jboes
parents: 58054
diff changeset
   182
     * @throws     IOException  if an I/O error occurs.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
    public void flush() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * Closes this output stream and releases any system resources
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   189
     * associated with this stream. The general contract of {@code close}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     * is that it closes the output stream. A closed stream cannot perform
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     * output operations and cannot be reopened.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     * <p>
58288
48e480e56aad 8231186: Replace html tag <code>foo</code> with javadoc tag {@code foo} in java.base
jboes
parents: 58242
diff changeset
   193
     * The {@code close} method of {@code OutputStream} does nothing.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     *
58242
94bb65cb37d3 8230648: Replace @exception tag with @throws in java.base
jboes
parents: 58054
diff changeset
   195
     * @throws     IOException  if an I/O error occurs.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    public void close() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
}