RandomAccessFile: writeInt(int v) : RandomAccessFile « java.io « Java by API






RandomAccessFile: writeInt(int v)

 
import java.io.IOException;
import java.io.RandomAccessFile;

public class Main {
  public static void main(String[] args) {
    try {
      RandomAccessFile raf = new RandomAccessFile("c:\\temp\\RAFsample.txt", "rw");
      raf.writeInt(10);
      raf.writeInt(43);
      raf.writeInt(88);
      raf.writeInt(455);

      raf.seek((3 - 1) * 4);
      raf.writeInt(99);
      raf.seek(0); 
      int i = raf.readInt();
      while (i != -1) {
        System.out.println(i);

        i = raf.readInt();
      }
      raf.close();
    } catch (IOException e) {
    }
  }
}

   
  








Related examples in the same category

1.new RandomAccessFile(String fileName, String mode)
2.RandomAccessFile: close()
3.RandomAccessFile: getChannel()
4.RandomAccessFile: getFilePointer()
5.RandomAccessFile: length()
6.RandomAccessFile: read(byte[] b)
7.RandomAccessFile: readBoolean()
8.RandomAccessFile: readByte()
9.RandomAccessFile: readChar()
10.RandomAccessFile: readDouble()
11.RandomAccessFile: readInt()
12.RandomAccessFile: readLine()
13.RandomAccessFile: seek(long pos)
14.RandomAccessFile: write(byte[] b)
15.RandomAccessFile: writeBoolean(boolean v)
16.RandomAccessFile: writeBytes(String s)
17.RandomAccessFile: writeChar(int v)
18.RandomAccessFile: writeChars(String s)
19.RandomAccessFile: writeDouble(double v)
20.RandomAccessFile: writeUTF(String str)