Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.io.DataOutputStream;
import java.io.File;
import java.io.FileOutputStream;

public class Main {
    public static void main(String[] args) {
        String destFile = "primitives.dat";

        try (DataOutputStream dos = new DataOutputStream(new FileOutputStream(destFile))) {
            dos.writeInt(765);
            dos.writeDouble(6789.50);
            dos.writeBoolean(true);
            dos.writeUTF("Java Input/Output  is cool!");

            dos.flush();

            System.out.println("Data has  been  written to " + (new File(destFile)).getAbsolutePath());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}