RandomAccessFile: readDouble() : RandomAccessFile « java.io « Java by API






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();

  }
}

   
  








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: readInt()
11.RandomAccessFile: readLine()
12.RandomAccessFile: seek(long pos)
13.RandomAccessFile: write(byte[] b)
14.RandomAccessFile: writeBoolean(boolean v)
15.RandomAccessFile: writeBytes(String s)
16.RandomAccessFile: writeChar(int v)
17.RandomAccessFile: writeChars(String s)
18.RandomAccessFile: writeDouble(double v)
19.RandomAccessFile: writeInt(int v)
20.RandomAccessFile: writeUTF(String str)