Java FileChannel get from RandomAccessFile
import java.io.RandomAccessFile; import java.nio.channels.FileChannel; public class Main { public static void main(String[] args) throws Exception { // Create a random access file and obtain a channel for it RandomAccessFile raf = new RandomAccessFile("Main.java", "rw"); FileChannel fileChannel = raf.getChannel(); fileChannel.close();// ww w. j a v a 2s . com raf.close(); } }