Is there a non-blocking file read API in java? If not would it be wise to build one in C++ and call it from a java app via JNI?
No, FileChannel
does not extend SelectableChannel
.
Probably because not all OSes support it.
Windows does, and in theory you could write a windows-specific C++ library and call it via JNI, but it is a lot of work to integrate this with java.nio
.
I would rather have a worker thread copy the file contents to a pipe and do non-blocking reads on the other end of the pipe.