Create RandomAccessFile from File object : RandomAccessFile « File « SCJP






import java.io.*;
public class MainClass{
    public static void main(String[] argv) throws FileNotFoundException{
         File file = new File("test.dat");
        
         RandomAccessFile raf = new RandomAccessFile(file, "rw");
    }
}








9.2.RandomAccessFile
9.2.1.Create RandomAccessFile from File object
9.2.2.A RandomAccessFile has a file pointer
9.2.3.'long getFilePointer() throws IOException' returns the current position within the file in bytes.
9.2.4.'long length()' throws IOException Returns the length of the file, in bytes.
9.2.5.'void seek(long position) throws IOException' Sets the current position within the file, in bytes.