public class NioUtils extends Object
Modifier and Type | Field and Description |
---|---|
static int |
NIO_TIMEOUT
The number of milliseconds after which NIO operation will time out.
|
Modifier and Type | Method and Description |
---|---|
static void |
copy(FileChannel fileChannel,
WritableByteChannel writableChannel)
Writes the representation to a byte channel.
|
static void |
copy(ReadableByteChannel readableChannel,
OutputStream outputStream)
Writes a NIO readable channel to a BIO output stream.
|
static void |
copy(ReadableByteChannel readableChannel,
WritableByteChannel writableChannel)
Writes a readable channel to a writable channel.
|
static ReadableByteChannel |
getChannel(InputStream inputStream)
Returns a readable byte channel based on a given input stream.
|
static WritableByteChannel |
getChannel(OutputStream outputStream)
Returns a writable byte channel based on a given output stream.
|
static ReadableByteChannel |
getChannel(Representation representation)
Returns a readable byte channel based on the given representation's
content and its write(WritableByteChannel) method.
|
static InputStream |
getStream(ReadableByteChannel readableChannel)
Returns an input stream based on a given readable byte channel.
|
static OutputStream |
getStream(WritableByteChannel writableChannel)
Returns an output stream based on a given writable byte channel.
|
static boolean |
isBlocking(Channel channel)
Indicates if the channel is in blocking mode.
|
static void |
release(Selector selector,
SelectionKey selectionKey)
Release the selection key, working around for bug #6403933.
|
static void |
waitForState(SelectableChannel selectableChannel,
int operations)
Waits for the given channel to be ready for a specific operation.
|
public static final int NIO_TIMEOUT
public static void copy(FileChannel fileChannel, WritableByteChannel writableChannel) throws IOException
fileChannel
- The readable file channel.writableChannel
- A writable byte channel.IOException
public static void copy(ReadableByteChannel readableChannel, OutputStream outputStream) throws IOException
readableChannel
- The readable channel.outputStream
- The output stream.IOException
public static void copy(ReadableByteChannel readableChannel, WritableByteChannel writableChannel) throws IOException
readableChannel
- The readable channel.writableChannel
- The writable channel.IOException
public static ReadableByteChannel getChannel(InputStream inputStream)
inputStream
- The input stream to convert.public static WritableByteChannel getChannel(OutputStream outputStream)
outputStream
- The output stream.public static ReadableByteChannel getChannel(Representation representation) throws IOException
representation
- the representation to get the OutputStream
from.IOException
public static InputStream getStream(ReadableByteChannel readableChannel)
readableChannel
- The readable byte channel.public static OutputStream getStream(WritableByteChannel writableChannel)
writableChannel
- The writable byte channel.public static boolean isBlocking(Channel channel)
channel
- The channel to test.public static void release(Selector selector, SelectionKey selectionKey) throws IOException
selector
- The associated selector.selectionKey
- The used selection key.IOException
public static void waitForState(SelectableChannel selectableChannel, int operations) throws IOException
selectableChannel
- The channel to monitor.operations
- The operations to be ready to do.IOException
Copyright © 2005–2016. All rights reserved.