public class NioUtils
extends java.lang.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(java.nio.channels.FileChannel fileChannel,
java.nio.channels.WritableByteChannel writableChannel)
Writes the representation to a byte channel.
|
static void |
copy(java.nio.channels.ReadableByteChannel readableChannel,
java.io.OutputStream outputStream)
Writes a NIO readable channel to a BIO output stream.
|
static void |
copy(java.nio.channels.ReadableByteChannel readableChannel,
java.nio.channels.WritableByteChannel writableChannel)
Writes a readable channel to a writable channel.
|
static java.nio.channels.ReadableByteChannel |
getChannel(java.io.InputStream inputStream)
Returns a readable byte channel based on a given input stream.
|
static java.nio.channels.WritableByteChannel |
getChannel(java.io.OutputStream outputStream)
Returns a writable byte channel based on a given output stream.
|
static java.nio.channels.ReadableByteChannel |
getChannel(Representation representation)
Returns a readable byte channel based on the given representation's
content and its write(WritableByteChannel) method.
|
static java.io.InputStream |
getStream(java.nio.channels.ReadableByteChannel readableChannel)
Returns an input stream based on a given readable byte channel.
|
static java.io.OutputStream |
getStream(java.nio.channels.WritableByteChannel writableChannel)
Returns an output stream based on a given writable byte channel.
|
static boolean |
isBlocking(java.nio.channels.Channel channel)
Indicates if the channel is in blocking mode.
|
static void |
release(java.nio.channels.Selector selector,
java.nio.channels.SelectionKey selectionKey)
Release the selection key, working around for bug #6403933.
|
static void |
waitForState(java.nio.channels.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(java.nio.channels.FileChannel fileChannel, java.nio.channels.WritableByteChannel writableChannel) throws java.io.IOException
fileChannel
- The readable file channel.writableChannel
- A writable byte channel.java.io.IOException
public static void copy(java.nio.channels.ReadableByteChannel readableChannel, java.io.OutputStream outputStream) throws java.io.IOException
readableChannel
- The readable channel.outputStream
- The output stream.java.io.IOException
public static void copy(java.nio.channels.ReadableByteChannel readableChannel, java.nio.channels.WritableByteChannel writableChannel) throws java.io.IOException
readableChannel
- The readable channel.writableChannel
- The writable channel.java.io.IOException
public static java.nio.channels.ReadableByteChannel getChannel(java.io.InputStream inputStream)
inputStream
- The input stream to convert.public static java.nio.channels.WritableByteChannel getChannel(java.io.OutputStream outputStream)
outputStream
- The output stream.public static java.nio.channels.ReadableByteChannel getChannel(Representation representation) throws java.io.IOException
representation
- the representation to get the OutputStream
from.java.io.IOException
public static java.io.InputStream getStream(java.nio.channels.ReadableByteChannel readableChannel)
readableChannel
- The readable byte channel.public static java.io.OutputStream getStream(java.nio.channels.WritableByteChannel writableChannel)
writableChannel
- The writable byte channel.public static boolean isBlocking(java.nio.channels.Channel channel)
channel
- The channel to test.public static void release(java.nio.channels.Selector selector, java.nio.channels.SelectionKey selectionKey) throws java.io.IOException
selector
- The associated selector.selectionKey
- The used selection key.java.io.IOException
public static void waitForState(java.nio.channels.SelectableChannel selectableChannel, int operations) throws java.io.IOException
selectableChannel
- The channel to monitor.operations
- The operations to be ready to do.java.io.IOException
Copyright © 2005-2012. All Rights Reserved.