Class SelectableFileChannelFactory


public class SelectableFileChannelFactory extends Object
Extracts out 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()

Kohsuke Kawaguchi