< prev index next >

src/java.base/share/classes/java/io/PipedWriter.java

Print this page




 130      * This method blocks until all the characters are written to the output
 131      * stream.
 132      * If a thread was reading data characters from the connected piped input
 133      * stream, but the thread is no longer alive, then an
 134      * {@code IOException} is thrown.
 135      *
 136      * @param      cbuf  the data.
 137      * @param      off   the start offset in the data.
 138      * @param      len   the number of characters to write.
 139      *
 140      * @throws  IndexOutOfBoundsException
 141      *          If {@code off} is negative, or {@code len} is negative,
 142      *          or {@code off + len} is negative or greater than the length
 143      *          of the given array
 144      *
 145      * @throws  IOException  if the pipe is
 146      *          <a href=PipedOutputStream.html#BROKEN><code>broken</code></a>,
 147      *          {@link #connect(java.io.PipedReader) unconnected}, closed
 148      *          or an I/O error occurs.
 149      */
 150     public void write(char cbuf[], int off, int len) throws IOException {
 151         if (sink == null) {
 152             throw new IOException("Pipe not connected");
 153         } else if ((off | len | (off + len) | (cbuf.length - (off + len))) < 0) {
 154             throw new IndexOutOfBoundsException();
 155         }
 156         sink.receive(cbuf, off, len);
 157     }
 158 
 159     /**
 160      * Flushes this output stream and forces any buffered output characters
 161      * to be written out.
 162      * This will notify any readers that characters are waiting in the pipe.
 163      *
 164      * @exception  IOException  if the pipe is closed, or an I/O error occurs.
 165      */
 166     public synchronized void flush() throws IOException {
 167         if (sink != null) {
 168             if (sink.closedByReader || closed) {
 169                 throw new IOException("Pipe closed");
 170             }


 130      * This method blocks until all the characters are written to the output
 131      * stream.
 132      * If a thread was reading data characters from the connected piped input
 133      * stream, but the thread is no longer alive, then an
 134      * {@code IOException} is thrown.
 135      *
 136      * @param      cbuf  the data.
 137      * @param      off   the start offset in the data.
 138      * @param      len   the number of characters to write.
 139      *
 140      * @throws  IndexOutOfBoundsException
 141      *          If {@code off} is negative, or {@code len} is negative,
 142      *          or {@code off + len} is negative or greater than the length
 143      *          of the given array
 144      *
 145      * @throws  IOException  if the pipe is
 146      *          <a href=PipedOutputStream.html#BROKEN><code>broken</code></a>,
 147      *          {@link #connect(java.io.PipedReader) unconnected}, closed
 148      *          or an I/O error occurs.
 149      */
 150     public void write(char[] cbuf, int off, int len) throws IOException {
 151         if (sink == null) {
 152             throw new IOException("Pipe not connected");
 153         } else if ((off | len | (off + len) | (cbuf.length - (off + len))) < 0) {
 154             throw new IndexOutOfBoundsException();
 155         }
 156         sink.receive(cbuf, off, len);
 157     }
 158 
 159     /**
 160      * Flushes this output stream and forces any buffered output characters
 161      * to be written out.
 162      * This will notify any readers that characters are waiting in the pipe.
 163      *
 164      * @exception  IOException  if the pipe is closed, or an I/O error occurs.
 165      */
 166     public synchronized void flush() throws IOException {
 167         if (sink != null) {
 168             if (sink.closedByReader || closed) {
 169                 throw new IOException("Pipe closed");
 170             }
< prev index next >