数组也是Object
用ObjectInputStream.readObject()和ObjectOutputStream.writeObject()
数组元素必须是简单类型或者实现java.io.Serializable接口
用ObjectInputStream.readObject()和ObjectOutputStream.writeObject()
数组元素必须是简单类型或者实现java.io.Serializable接口
{
byte[] bx = new byte[1];
try
{
ObjectOutputStream fin;
ByteArrayOutputStream b = new ByteArrayOutputStream();
fin = new ObjectOutputStream(b);
fin.writeObject(data);
fin.flush();
fin.close();
fin = null;
bx = new byte[b.size()];
bx = b.toByteArray();
}
catch(Exception e)
{
log(" bAppending/writing object data error : " + e.toString());
}
return bx;
}
public static Object breaddato(byte[] data)
{
Object bx = new Object();
try
{
ObjectInputStream fin;
ByteArrayInputStream b = new ByteArrayInputStream(data);
fin = new ObjectInputStream(b);
bx = fin.readObject();
fin.close();
fin = null;
}
catch(Exception e)
{
log(" bAppending/writing object data error : " + e.toString());
}
return bx;
}