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();
View Code

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-26
  • 2021-12-30
  • 2022-12-23
  • 2022-12-23
  • 2021-11-03
猜你喜欢
  • 2022-02-02
  • 2022-02-14
  • 2022-12-23
  • 2021-09-09
  • 2021-11-12
  • 2022-12-23
相关资源
相似解决方案