Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.io.FileOutputStream;
import java.io.ObjectOutputStream;
import java.util.Hashtable;

public class Main {
    public static void main(String[] args) throws Exception {
        Hashtable h = new Hashtable();
        h.put("string", "AAA");
        h.put("int", new Integer(26));
        h.put("double", new Double(Math.PI));

        FileOutputStream fileOut = new FileOutputStream("hashtable.ser");
        ObjectOutputStream out = new ObjectOutputStream(fileOut);
        out.writeObject(h);

        FileInputStream fileIn = new FileInputStream("h.ser");
        ObjectInputStream in = new ObjectInputStream(fileIn);
        Hashtable h = (Hashtable) in.readObject();
        System.out.println(h.toString());
    }
}