Package org.xnio.streams
Class ChannelOutputStream
java.lang.Object
java.io.OutputStream
org.xnio.streams.ChannelOutputStream
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
An output stream which writes to a stream sink channel. All write operations are directly
performed upon the channel, so for optimal performance, a buffering output stream should be
used to wrap this class.
- Since:
- 1.2
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionChannelOutputStream
(StreamSinkChannel channel) Construct a new instance.ChannelOutputStream
(StreamSinkChannel channel, long timeout, TimeUnit unit) Construct a new instance. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
void
flush()
long
getWriteTimeout
(TimeUnit unit) Get the write timeout.void
setWriteTimeout
(long timeout, TimeUnit unit) Set the write timeout.void
write
(byte[] b) void
write
(byte[] b, int off, int len) void
write
(int b) Methods inherited from class java.io.OutputStream
nullOutputStream
-
Field Details
-
channel
-
-
Constructor Details
-
ChannelOutputStream
Construct a new instance. No write timeout is configured.- Parameters:
channel
- the channel to wrap
-
ChannelOutputStream
Construct a new instance.- Parameters:
channel
- the channel to wraptimeout
- the write timeoutunit
- the write timeout units
-
-
Method Details
-
getWriteTimeout
Get the write timeout.- Parameters:
unit
- the time unit- Returns:
- the timeout in the given unit
-
setWriteTimeout
Set the write timeout. Does not affect write operations in progress.- Parameters:
timeout
- the write timeout, or 0 for noneunit
- the time unit
-
write
- Specified by:
write
in classOutputStream
- Throws:
IOException
-
write
- Overrides:
write
in classOutputStream
- Throws:
IOException
-
write
- Overrides:
write
in classOutputStream
- Throws:
IOException
-
flush
- Specified by:
flush
in interfaceFlushable
- Overrides:
flush
in classOutputStream
- Throws:
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classOutputStream
- Throws:
IOException
-