Java tutorial
import java.io.*; public class Main { public static void main(String[] args) { try { int i = 123; RandomAccessFile raf = new RandomAccessFile("c:/test.txt", "rw"); // write something in the file raf.writeInt(123); // set the file pointer at 0 position raf.seek(0); // print the int System.out.println(raf.readInt()); // set the file pointer at 0 position raf.seek(0); // write something in the file raf.writeInt(i); // set the file pointer at 0 position raf.seek(0); // print the int System.out.println(raf.readInt()); raf.close(); } catch (IOException ex) { ex.printStackTrace(); } } }