- You can open a file either for
- Reading only ("r")
- Reading and writing ("rw")
RandomAccessFile f = new RandomAcessFile("bank.dat","rw");
- To move the file pointer to a specific byte
f.seek(n);
- To get the current position of the file pointer.
long n = f.getFilePointer(); // of type "long" because files can be very large
- To find the number of bytes in a file
long fileLength = f.length();