RandomAccessFile.write(byte[] b) has the following syntax.
public void write(byte[] b) throws IOException
In the following code shows how to use RandomAccessFile.write(byte[] b) method.
/* w ww . ja va 2s.c om*/ import java.io.*; public class Main { public static void main(String[] args) { try { byte[] b = {1}; RandomAccessFile raf = new RandomAccessFile("c:/test.txt", "rw"); raf.write(b); // set the file pointer at 0 position raf.seek(0); System.out.println(raf.readByte()); raf.close(); } catch (IOException ex) { ex.printStackTrace(); } } }