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 IOException
{
vector.add(b + "");
}
}
class MyInputStream extends InputStream
{
public Vector vector;
public int read()
throws java.io.IOException
{
String result = (String) vector.get(0);
int iresult = Integer.parseInt(result, 10);
vector.remove(0);
return iresult;
}
}