1700439026
1700439027
private static String FILE_NAME=“c:/obj.bin”;
1700439028
1700439029
//序列化
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
}
[
上一页 ]
[ :1.700439026e+09 ]
[
下一页 ]