Presented below is an example of ObjectOutputStream:

Java Code:
try {
    ObjectOutput os = new ObjectOutputStream(System.out);
    os.writeObject(new JButton("Press Me"});
    os.close();
} catch(Exception e) {
    e.printStackTrace();
}