Writing process:
OutputStream out= ... ; // any output stream ObjectOutputStream objOut= new ObjectOutputStream(out); objOut.writeInt(i); // throws IOException objOut.writeObject(space); // throws IOException ...