[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/RoyTien/Java-Programming-Exercises/master/Box.java [Back]  [Original]

import java.io.*;	//import

public class Box implements Serializable{
	//,Java
	private int width;
	private int height;

	public void setWidth(int w){
		width = w;
	}
	public void setHeight(int h){
		height = h;
	}

	public static void main(String[] args){
		Box myBox = new Box();
		myBox.setWidth(50);
		myBox.setHeight(20);

		try{
			FileOutputStream fs = new FileOutputStream("foo.ser");
			//
			ObjectOutputStream os = new ObjectOutputStream(fs);
			os.writeObject(myBox);
			os.close();
		}catch(Exception ex){
			ex.printStackTrace();
		}
	}
}

Web Proxy Viewer  |  New URL  |  Original Page