public class SocketOutputStream extends FilterOutputStream
SocketInputStream
out
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, write
public 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 FilterOutputStream
buffer
- 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 Closeable
close
in interface AutoCloseable
close
in class FilterOutputStream
IOException
- If there is an error in closing the stream
or socket.Copyright © 2001–2016 The Apache Software Foundation. All rights reserved.