List of usage examples for java.io ObjectStreamConstants PROTOCOL_VERSION_1
int PROTOCOL_VERSION_1
To view the source code for java.io ObjectStreamConstants PROTOCOL_VERSION_1.
Click Source Link
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);/*from w w w. ja va 2 s. co m*/ 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(); }