|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.OutputStream
org.apache.hadoop.net.SocketOutputStream
public class SocketOutputStream
This implements an output stream that can have a timeout while writing.
This sets non-blocking flag on the socket channel.
So after creating this object , read() on
Socket.getInputStream()
and write() on
Socket.getOutputStream()
on the associated socket will throw
llegalBlockingModeException.
Please use SocketInputStream
for reading.
Constructor Summary | |
---|---|
SocketOutputStream(Socket socket,
long timeout)
Same as SocketOutputStream(socket.getChannel(), timeout): Create a new ouput stream with the given timeout. |
|
SocketOutputStream(WritableByteChannel channel,
long timeout)
Create a new ouput stream with the given timeout. |
Method Summary | |
---|---|
void |
close()
|
WritableByteChannel |
getChannel()
Returns underlying channel used by this stream. |
boolean |
isOpen()
|
void |
write(byte[] b,
int off,
int len)
|
int |
write(ByteBuffer src)
|
void |
write(int b)
|
Methods inherited from class java.io.OutputStream |
---|
flush, write |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SocketOutputStream(WritableByteChannel channel, long timeout) throws IOException
channel
- Channel for writing, should also be a SelectableChannel
.
The channel will be configured to be non-blocking.timeout
- timeout in milliseconds. must not be negative.
IOException
public SocketOutputStream(Socket socket, long timeout) throws IOException
socket
- should have a channel associated with it.timeout
- timeout timeout in milliseconds. must not be negative.
IOException
SocketOutputStream(WritableByteChannel, long)
Method Detail |
---|
public void write(int b) throws IOException
write
in class OutputStream
IOException
public void write(byte[] b, int off, int len) throws IOException
write
in class OutputStream
IOException
public void close() throws IOException
close
in interface Closeable
close
in interface Channel
close
in class OutputStream
IOException
public WritableByteChannel getChannel()
FileChannel.transferTo(long, long, WritableByteChannel)
public boolean isOpen()
isOpen
in interface Channel
public int write(ByteBuffer src) throws IOException
write
in interface WritableByteChannel
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |