RandomAccessFile: readInt()
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) {
}
}
}
Home
Java Book
File Stream
Java Book
File Stream
RandomAccessFile:
- RandomAccessFile
- new RandomAccessFile(String fileName, String mode)
- RandomAccessFile: close()
- RandomAccessFile: getChannel()
- RandomAccessFile: getFilePointer()
- RandomAccessFile: length()
- RandomAccessFile: read(byte[] b)
- RandomAccessFile: readBoolean()
- RandomAccessFile: readByte()
- RandomAccessFile: readChar()
- RandomAccessFile: readDouble()
- RandomAccessFile: readInt()
- RandomAccessFile: readLine()
- RandomAccessFile: seek(long pos)
- RandomAccessFile: write(byte[] b)
- RandomAccessFile: writeBoolean(boolean v)
- RandomAccessFile: writeBytes(String s)
- RandomAccessFile: writeChars(String s)
- RandomAccessFile: writeInt(int v)
- RandomAccessFile: writeUTF(String str)