package
com.ssal;
import
java.io.ByteArrayInputStream;
import
java.io.ByteArrayOutputStream;
import
java.io.ObjectInputStream;
import
java.io.ObjectOutputStream;
public
class
Snippet
{
public static void main(String[] args) throws
Exception
{
Integer a =
new
Integer(1);
ByteArrayOutputStream buf =
new
ByteArrayOutputStream();
ObjectOutputStream o =
new
ObjectOutputStream(buf);
o.writeObject(a);
// Now get copies:
ObjectInputStream in =
new ObjectInputStream(new
ByteArrayInputStream(buf.toByteArray()));
Integer b = (Integer) in.readObject();
System.
out
.println(a);
a = 12;
System.
out
.println(b);
分享到:
评论