Java???л??????л??????????
???????????? ???????[ 2012/8/14 10:16:17 ] ????????
???????????л?
????Java?е????л???serialization???????????????????????????д???????????У??????????socket???д???????????洢??????????????У???????????????????????????е???????????????????????л???????Java?????????????EJB??RMI????????????????????
?????????????л?????
??????????????????????????л??????????java.io.Serializable??????????????????????????????y???????????????????????????κ???????????y????????????????????л?????????????????????Person????????????????л???
public class Person implements Serializable {
private static final long serialVersionUID = 1L;
private String name;;
private int age;
public Person(){
}
public Person(String str??int n){
System.out.println("Inside Person's Constructor");
name = str;
age = n;
}
public String getName() {
return name;
}
public int getAge() {
return age;
}
}
???????????????????????
????1???????
public class SerializeToFlatFile {
public static void main(String[] args) {
SerializeToFlatFile ser = new SerializeToFlatFile();
ser.savePerson();
ser.restorePerson();
}
public void savePerson(){
Person myPerson = new Person("Jay"?? 24);
try{
FileOutputStream fos = new FileOutputStream("E:\person.txt");
ObjectOutputStream oos = new ObjectOutputStream(fos);
System.out.println("Person--Jay??24---Written");
oos.writeObject(myPerson);
oos.flush();
oos.close();
}catch(Exception e){
e.printStackTrace();
}
}
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11