shutdown.java Source code

Java tutorial

Introduction

Here is the source code for shutdown.java

Source

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

class shutdown {
    public static void main(String[] args) throws ClassNotFoundException, IOException {
        FileOutputStream fos = new FileOutputStream("objects.tmp");

        ObjectOutputStream oos = new ObjectOutputStream(fos);
        oos.writeObject("asdf");
        oos.flush();
        fos.close();

        FileInputStream fis = new FileInputStream("objects.tmp");
        ObjectInputStream ois = new ObjectInputStream(fis);
        String t = (String) ois.readObject();
        fis.close();

    }
}