118 public void write(int b) throws IOException {
119 if (sink == null) {
120 throw new IOException("Pipe not connected");
121 }
122 sink.receive(b);
123 }
124
125 /**
126 * Writes <code>len</code> bytes from the specified byte array
127 * starting at offset <code>off</code> to this piped output stream.
128 * This method blocks until all the bytes are written to the output
129 * stream.
130 *
131 * @param b the data.
132 * @param off the start offset in the data.
133 * @param len the number of bytes to write.
134 * @exception IOException if the pipe is <a href=#BROKEN> broken</a>,
135 * {@link #connect(java.io.PipedInputStream) unconnected},
136 * closed, or if an I/O error occurs.
137 */
138 public void write(byte b[], int off, int len) throws IOException {
139 if (sink == null) {
140 throw new IOException("Pipe not connected");
141 } else if (b == null) {
142 throw new NullPointerException();
143 } else if ((off < 0) || (off > b.length) || (len < 0) ||
144 ((off + len) > b.length) || ((off + len) < 0)) {
145 throw new IndexOutOfBoundsException();
146 } else if (len == 0) {
147 return;
148 }
149 sink.receive(b, off, len);
150 }
151
152 /**
153 * Flushes this output stream and forces any buffered output bytes
154 * to be written out.
155 * This will notify any readers that bytes are waiting in the pipe.
156 *
157 * @exception IOException if an I/O error occurs.
158 */
|
118 public void write(int b) throws IOException {
119 if (sink == null) {
120 throw new IOException("Pipe not connected");
121 }
122 sink.receive(b);
123 }
124
125 /**
126 * Writes <code>len</code> bytes from the specified byte array
127 * starting at offset <code>off</code> to this piped output stream.
128 * This method blocks until all the bytes are written to the output
129 * stream.
130 *
131 * @param b the data.
132 * @param off the start offset in the data.
133 * @param len the number of bytes to write.
134 * @exception IOException if the pipe is <a href=#BROKEN> broken</a>,
135 * {@link #connect(java.io.PipedInputStream) unconnected},
136 * closed, or if an I/O error occurs.
137 */
138 public void write(byte[] b, int off, int len) throws IOException {
139 if (sink == null) {
140 throw new IOException("Pipe not connected");
141 } else if (b == null) {
142 throw new NullPointerException();
143 } else if ((off < 0) || (off > b.length) || (len < 0) ||
144 ((off + len) > b.length) || ((off + len) < 0)) {
145 throw new IndexOutOfBoundsException();
146 } else if (len == 0) {
147 return;
148 }
149 sink.receive(b, off, len);
150 }
151
152 /**
153 * Flushes this output stream and forces any buffered output bytes
154 * to be written out.
155 * This will notify any readers that bytes are waiting in the pipe.
156 *
157 * @exception IOException if an I/O error occurs.
158 */
|