RandomAccessFile: readDouble()
import java.io.IOException;
import java.io.RandomAccessFile;
public class Main {
public static void main(String[] args) throws IOException {
RandomAccessFile rf = new RandomAccessFile("test.dat", "rw");
for (int i = 0; i < 10; i++)
rf.writeDouble(i * 1.414);
rf.close();
rf = new RandomAccessFile("test.dat", "rw");
rf.seek(5 * 8);
rf.writeDouble(47.0001);
rf.close();
rf = new RandomAccessFile("test.dat", "r");
for (int i = 0; i < 10; i++)
System.out.println("Value " + i + ": " + rf.readDouble());
rf.close();
}
}
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)