List of usage examples for java.io RandomAccessFile writeFloat
public final void writeFloat(float v) throws IOException
From source file:Main.java
public static void main(String[] args) { try {/* w w w .ja va 2 s. c om*/ float f = 1234.5678f; RandomAccessFile raf = new RandomAccessFile("c:/test.txt", "rw"); raf.writeFloat(f); raf.seek(0); System.out.println(raf.readFloat()); raf.seek(0); raf.writeFloat(123.4567f); raf.seek(0); System.out.println(raf.readFloat()); raf.close(); } catch (IOException ex) { ex.printStackTrace(); } }
From source file:Main.java
public static void main(String[] args) { try {// w w w .j ava 2s . c om float f = 1234.56f; RandomAccessFile raf = new RandomAccessFile("c:/test.txt", "rw"); // write something in the file raf.writeFloat(987.654f); // set the file pointer at 0 position raf.seek(0); // read float System.out.println(raf.readFloat()); // set the file pointer at 0 position raf.seek(0); // write a float raf.writeFloat(f); // set the file pointer at 0 position raf.seek(0); // read float System.out.println(raf.readFloat()); raf.close(); } catch (IOException ex) { ex.printStackTrace(); } }