Java RandomAccessFile .writeLong (long v)
Syntax
RandomAccessFile.writeLong(long v) has the following syntax.
public final void writeLong(long v) throws IOException
Example
In the following code shows how to use RandomAccessFile.writeLong(long v) method.
/*w w w . j a v a 2 s. c o m*/
import java.io.*;
public class Main {
public static void main(String[] args) {
try {
long f = 123456789909876L;
RandomAccessFile raf = new RandomAccessFile("c:/test.txt", "rw");
raf.writeLong(f);
raf.seek(0);
System.out.println(raf.readLong());
raf.seek(0);
raf.writeLong(20000000000l);
raf.seek(0);
System.out.println(raf.readLong());
raf.close();
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
Home »
Java Tutorial »
java.io »
Java Tutorial »
java.io »