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