- All Superinterfaces:
AutoCloseable
,Closeable
,Stream
- All Known Implementing Classes:
AbstractStreamWriter
,DefaultStreamWriter
,SSLStreamWriter
,TransformerStreamWriter
Write the primitive Java types and arrays of primitives to some data sink. This may include internal buffering for
efficiency reasons.
Note, that StreamWriter implementation may not be thread-safe.
- Author:
- Ken Cavanaugh, Alexey Stashok
-
Method Summary
Modifier and TypeMethodDescriptionclose
(CompletionHandler<Integer> completionHandler) Close theStreamWriter
and make sure all data was flushed.<E> GrizzlyFuture<Stream>
encode
(Transformer<E, Buffer> encoder, E object) <E> GrizzlyFuture<Stream>
encode
(Transformer<E, Buffer> encoder, E object, CompletionHandler<Stream> completionHandler) flush()
Make sure that all data that has been written is flushed from the stream to its destination.flush
(CompletionHandler<Integer> completionHandler) Make sure that all data that has been written is flushed from the stream to its destination.Get theConnection
this StreamWriter belongs to.long
getTimeout
(TimeUnit timeunit) Get the timeout for StreamWriter I/O operations.boolean
isClosed()
Returns true, if StreamReader has been closed, or false otherwise.void
setTimeout
(long timeout, TimeUnit timeunit) Set the timeout for StreamWriter I/O operations.void
writeBoolean
(boolean data) Write the boolean value to the StreamWriter.void
writeBooleanArray
(boolean[] data) Write the array of boolean values to the StreamWriter.void
writeBuffer
(Buffer buffer) Write theBuffer
to the StreamWriter.void
writeByte
(byte data) Write the byte value to the StreamWriter.void
writeByteArray
(byte[] data) Write the array of byte values to the StreamWriter.void
writeByteArray
(byte[] data, int offset, int length) Write the part of array of byte values to the StreamWriter, using specific offset and length values.void
writeChar
(char data) Write the char value to the StreamWriter.void
writeCharArray
(char[] data) Write the array of char values to the StreamWriter.void
writeDouble
(double data) Write the double value to the StreamWriter.void
writeDoubleArray
(double[] data) Write the array of double values to the StreamWriter.void
writeFloat
(float data) Write the float value to the StreamWriter.void
writeFloatArray
(float[] data) Write the array of float values to the StreamWriter.void
writeInt
(int data) Write the int value to the StreamWriter.void
writeIntArray
(int[] data) Write the array of int values to the StreamWriter.void
writeLong
(long data) Write the long value to the StreamWriter.void
writeLongArray
(long[] data) Write the array of long values to the StreamWriter.void
writeShort
(short data) Write the short value to the StreamWriter.void
writeShortArray
(short[] data) Write the array of short values to the StreamWriter.
-
Method Details
-
isClosed
boolean isClosed()Returns true, if StreamReader has been closed, or false otherwise.- Returns:
- true, if StreamReader has been closed, or false otherwise.
-
flush
Make sure that all data that has been written is flushed from the stream to its destination.- Throws:
IOException
-
flush
Make sure that all data that has been written is flushed from the stream to its destination.- Throws:
IOException
-
close
Close theStreamWriter
and make sure all data was flushed.- Throws:
IOException
-
writeBoolean
Write the boolean value to the StreamWriter.- Parameters:
data
- boolean value.- Throws:
IOException
-
writeByte
Write the byte value to the StreamWriter.- Parameters:
data
- byte value.- Throws:
IOException
-
writeChar
Write the char value to the StreamWriter.- Parameters:
data
- char value.- Throws:
IOException
-
writeShort
Write the short value to the StreamWriter.- Parameters:
data
- short value.- Throws:
IOException
-
writeInt
Write the int value to the StreamWriter.- Parameters:
data
- int value.- Throws:
IOException
-
writeLong
Write the long value to the StreamWriter.- Parameters:
data
- long value.- Throws:
IOException
-
writeFloat
Write the float value to the StreamWriter.- Parameters:
data
- float value.- Throws:
IOException
-
writeDouble
Write the double value to the StreamWriter.- Parameters:
data
- double value.- Throws:
IOException
-
writeBooleanArray
Write the array of boolean values to the StreamWriter.- Parameters:
data
- array of boolean values.- Throws:
IOException
-
writeByteArray
Write the array of byte values to the StreamWriter.- Parameters:
data
- array of byte values.- Throws:
IOException
-
writeByteArray
Write the part of array of byte values to the StreamWriter, using specific offset and length values.- Parameters:
data
- array of byte values.offset
- array offset to start from.length
- number of bytes to write.- Throws:
IOException
-
writeCharArray
Write the array of char values to the StreamWriter.- Parameters:
data
- array of char values.- Throws:
IOException
-
writeShortArray
Write the array of short values to the StreamWriter.- Parameters:
data
- array of short values.- Throws:
IOException
-
writeIntArray
Write the array of int values to the StreamWriter.- Parameters:
data
- array of int values.- Throws:
IOException
-
writeLongArray
Write the array of long values to the StreamWriter.- Parameters:
data
- array of long values.- Throws:
IOException
-
writeFloatArray
Write the array of float values to the StreamWriter.- Parameters:
data
- array of float values.- Throws:
IOException
-
writeDoubleArray
Write the array of double values to the StreamWriter.- Parameters:
data
- array of double values.- Throws:
IOException
-
writeBuffer
Write theBuffer
to the StreamWriter.- Parameters:
buffer
-Buffer
.- Throws:
IOException
-
encode
- Throws:
IOException
-
encode
<E> GrizzlyFuture<Stream> encode(Transformer<E, Buffer> encoder, E object, CompletionHandler<Stream> completionHandler) throws IOException- Throws:
IOException
-
getConnection
Connection getConnection()Get theConnection
this StreamWriter belongs to.- Specified by:
getConnection
in interfaceStream
- Returns:
- the
Connection
this StreamWriter belongs to.
-
getTimeout
Get the timeout for StreamWriter I/O operations.- Parameters:
timeunit
- timeout unitTimeUnit
.- Returns:
- the timeout for StreamWriter I/O operations.
-
setTimeout
Set the timeout for StreamWriter I/O operations.- Parameters:
timeout
- the timeout for StreamWriter I/O operations.timeunit
- timeout unitTimeUnit
.
-