1700439030
1700439031
public static void writeObject(Serializable s){
1700439032
1700439033
try{
1700439034
1700439035
ObjectOutputStream oos=new ObjectOutputStream(new
1700439036
1700439037
FileOutputStream(FILE_NAME));
1700439038
1700439039
oos.writeObject(s);
1700439040
1700439041
oos.close();
1700439042
1700439043
}catch(Exception e){
1700439044
1700439045
e.printStackTrace();
1700439046
1700439047
}
1700439048
1700439049
}
1700439050
1700439051
public static Object readObject(){
1700439052
1700439053
Object obj=null;
1700439054
1700439055
//反序列化
1700439056
1700439057
try{
1700439058
1700439059
Object Input in put=new Object Input Stream(new
1700439060
1700439061
FileInputStream(FILE_NAME));
1700439062
1700439063
obj=input.readObject();
1700439064
1700439065
input.close();
1700439066
1700439067
}catch(Exception e){
1700439068
1700439069
e.printStackTrace();
1700439070
1700439071
}
1700439072
1700439073
return obj;
1700439074
1700439075
}
1700439076
1700439077
}
1700439078
1700439079
通过对象序列化过程,把一个对象从内存块转化为可传输的数据流,然后通过网络发送到消息消费者(Consumer)那里,并进行反序列化,生成实例对象,代码如下:
[
上一页 ]
[ :1.70043903e+09 ]
[
下一页 ]