try { FileOutputStream fout = new FileOutputStream("innertest.ser"); ObjectOutputStream oout = new ObjectOutputStream(fout); oout.writeObject(new InnerTest()); oout.close(); } catch (IOException e) { System.err.println(e); e.printStackTrace(); }