A relatively complete serialization example.

zhaozj2021-02-16  82

Package Sample;

Import java.io.ioException;

Import java.io.outputstream;

Import java.util.vector;

Import Java.io.InputStream;

Public Class SampleApplication

{

Public static void main (string [] args)

Throws Exception

{

Myoutputstream mos = new myoutputstream ();

Java.io.ObjectOutputStream OS = New Java.io.ObjectOutputStream (MOS);

Os.writeObject (New Tester ());

MyinputStream Mis = new myinputstream ();

Mis.Vector = mos.vector;

Java.io.ObjectInputStream is = new java.io.objectInputStream (MIS);

System.out.println (is.readObject ());

}

}

Class Tester Implements Java.io.Serializable

{

Public String Hello = "Hello World."

Public String Tostring ()

{

Return this.Hello;

}

}

Class Myoutputstream Extends OutputStream

{

Public vector vector = new vector ();

Public Void Write (INT B)

Throws oException

{

Vector.Add (B "");

}

}

Class MyInputStream Extends InputStream

{

Public vector.

Public int tent ()

THROWS JAVA.IO.IOEXCEPTION

{

String result = (string) Vector.get (0);

INT IRESULT = INTEGER.PARSEINT (RESULT, 10);

Vector.Remove (0);

Return IRESULT;

}

}

转载请注明原文地址:https://www.9cbs.com/read-14850.html

New Post(0)