List of usage examples for java.io ObjectOutputStream useProtocolVersion
public void useProtocolVersion(int version) throws IOException
From source file:Person.java
public static void main(String[] args) throws Exception { ObjectOutputStream outputStream = new ObjectOutputStream(new FileOutputStream("yourFile.dat")); Person person = new Person(); person.setFirstName("A"); person.setLastName("B"); person.setAge(38);/* w ww .ja v a 2 s.c om*/ outputStream.writeObject(person); person = new Person(); person.setFirstName("C"); person.setLastName("D"); person.setAge(22); outputStream.writeObject(person); outputStream.useProtocolVersion(ObjectStreamConstants.PROTOCOL_VERSION_1); outputStream.close(); }