Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.io.IOException;
import java.io.RandomAccessFile;

public class Main {
    public static void main(String[] args) throws IOException {
        RandomAccessFile raf = new RandomAccessFile("employee.dat", "rw");

        raf.writeUTF("J");
        raf.writeUTF("S");
        raf.writeDouble(4.0);
        raf.seek(0L);
        String fname = raf.readUTF();
        String lname = raf.readUTF();
        double salary = raf.readDouble();
        System.out.println("First name = " + fname);
        System.out.println("Last name = " + lname);
        System.out.println("Salary = " + salary);
        raf.close();
    }
}