referee: Java NIO FileChannel
A java nio FileChannel is an channel that is connected to a file. Using a file channel you can read data from a file, and write data to a file. NIO is an alternative to reading files with the standard Java IO API.
A FileChannel cannot be set into non-blocking mode, and it's always runs in blocks mode.
Opening a FileChannel
To use an FileChannel, we should firstly open it. And we should obtain a FileChannel via in InputStream, OutputStream, or an RandomAccessFile. Here is how you can open a FileChannel via RandomChannel:
RandomAccessFile aFile = new RandomAccessFile("./testNewFile.txt", "rw"); FileChannel inChannel = aFile.getChannel();