001package serialization.fixedJavaSoftExample; 002import java.io.*; 003 004public class CardWriter { 005 public static void main(String[] args) { 006 Card2 card = new Card2(12, Card2.SPADES); 007 System.out.println("Card to write is: " + card); 008 009 try { 010 FileOutputStream out = new FileOutputStream("card.out"); 011 ObjectOutputStream oos = new ObjectOutputStream(out); 012 oos.writeObject(card); 013 oos.flush(); 014 oos.close(); 015 } catch (Exception e) { 016 System.out.println("Problem serializing: " + e); 017 } 018 } 019}