public class SocketOutputStream extends FilterOutputStream
SocketInputStreamout| Constructor and Description |
|---|
SocketOutputStream(Socket socket,
OutputStream stream)
Creates a SocketOutputStream instance wrapping an output stream and
storing a reference to a socket that should be closed on closing
the stream.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the stream and immediately afterward closes the referenced
socket.
|
void |
write(byte[] buffer,
int offset,
int length)
Writes a number of bytes from a byte array to the stream starting from
a given offset.
|
flush, write, writepublic SocketOutputStream(Socket socket, OutputStream stream)
socket - The socket to close on closing the stream.stream - The input stream to wrap.public void write(byte[] buffer, int offset, int length) throws IOException
write in class FilterOutputStreambuffer - The byte array to write.offset - The offset into the array at which to start copying data.length - The number of bytes to write.IOException - If an error occurs while writing to the underlying
stream.public void close() throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class FilterOutputStreamIOException - If there is an error in closing the stream
or socket.Copyright © 2001–2017 The Apache Software Foundation. All rights reserved.