public class SelectableFileChannelFactory extends Object
SelectableChannel from InputStream or OutputStream.
This hides the hack that works around the fact that FileChannel is not a SelectableChannel.
JDK didn't make FileChannel selectable because it's not selectable on Windows.
But on POSIX, select API does support arbitrary file descriptors, including pipes and regular files.
Methods on this class takes various JDK objects that own FileDescriptor and
creates a SocketChannel object that points to the same file descriptor, as a hack.
Note that since it is not a real socket, various socket specific operations on SocketChannel
will fail, most notably Object.toString()
| Constructor and Description |
|---|
SelectableFileChannelFactory() |
| Modifier and Type | Method and Description |
|---|---|
SocketChannel |
create(FileDescriptor fd) |
SocketChannel |
create(FileInputStream in) |
SocketChannel |
create(FileOutputStream out) |
SocketChannel |
create(InputStream in) |
SocketChannel |
create(OutputStream out) |
protected FileInputStream |
unwrap(InputStream i) |
protected FileOutputStream |
unwrap(OutputStream i) |
protected FileInputStream unwrap(InputStream i)
protected FileOutputStream unwrap(OutputStream i)
public SocketChannel create(InputStream in) throws IOException
IOExceptionpublic SocketChannel create(OutputStream out) throws IOException
IOExceptionpublic SocketChannel create(FileInputStream in) throws IOException
IOExceptionpublic SocketChannel create(FileOutputStream out) throws IOException
IOExceptionpublic SocketChannel create(FileDescriptor fd)
Copyright © 2004-2014. All Rights Reserved.