public class SocketOutputStream
extends java.io.FilterOutputStream
SocketInputStream
Constructor and Description |
---|
SocketOutputStream(java.net.Socket socket,
java.io.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.
|
public SocketOutputStream(java.net.Socket socket, java.io.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 java.io.IOException
write
in class java.io.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.java.io.IOException
- If an error occurs while writing to the underlying
stream.public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class java.io.FilterOutputStream
java.io.IOException
- If there is an error in closing the stream
or socket.