コード
import java.io.*;
public class WeightAndHeight implements Serializable{
private int weight;
private int height;
public void setWeight(int w) {
weight = w;
}
public void setHeight(int h) {
height = h;
}
public static void main(String[] args) {
WeightAndHeight ore = new WeightAndHeight();
ore.setHeight(200);
ore.setWeight(100);
try {
FileOutputStream fs = new FileOutputStream("Ore.ser");
ObjectOutputStream os = new ObjectOutputStream(fs);
os.writeObject(ore);
os.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}