import java.io.ObjectInputStream;
import java.io.FileInputStream;
import java.lang.Exception;

public class Read {

	public static void main(String [] args) {
		try {

			// Read from disk using FileInputStream
			FileInputStream f_in = new 
				FileInputStream("myobject.data");

			// Read object using ObjectInputStream
			ObjectInputStream obj_in = 
				new ObjectInputStream (f_in);

			// Read an object
			Object obj = obj_in.readObject();

			if (obj instanceof Data)
			{
				Data d = (Data) obj;
				System.out.println("User "+ d.username);
			}
		} catch(Exception ex)
		{
			ex.printStackTrace();
		}
	}
}

