Example usage for java.io ObjectStreamConstants PROTOCOL_VERSION_1

List of usage examples for java.io ObjectStreamConstants PROTOCOL_VERSION_1

Introduction

In this page you can find the example usage for java.io ObjectStreamConstants PROTOCOL_VERSION_1.

Prototype

int PROTOCOL_VERSION_1

To view the source code for java.io ObjectStreamConstants PROTOCOL_VERSION_1.

Click Source Link

Document

A Stream Protocol Version.

Usage

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();
}