import java.io.*;
@SuppressWarnings("serial")
class Person implements Serializable {
public Person(String name, String sex, int age, int height) {
this.name = name;
this.sex = sex;
this.age = age;
this.height = height;
}
public String toString() {
return "|" + this.name + "|" + this.sex + "|" + this.age + "|"
+ this.height + "|";
}
public String name;
public String sex;
public int age;
public int height;
}
public class SerialTest {
public static void main(String[] args) throws FileNotFoundException,
IOException, ClassNotFoundException {
Person p = new Person("Jim", "male", 28, 194);
// 开始序列化
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(
new File("myTest.txt")));
oos.writeObject(p);
// 反序列化
ObjectInputStream ois = new ObjectInputStream(new FileInputStream(
new File("myTest.txt")));
Person p1 = (Person) ois.readObject();
System.out.println(p1.toString());
}
}
import java.io.*;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver;
@SuppressWarnings("serial")
class RoadInfo implements Serializable {
public int id;
public long MDN;
public String NAME;
public double LNG;
public double LAT;
public String ICON;
}
@SuppressWarnings("serial")
class table_list implements Serializable {
public String toString() {
StringBuffer sb = new StringBuffer();
for (RoadInfo r : sequence) {
sb.append("|");
sb.append(r.id);
sb.append("|");
sb.append(r.MDN);
sb.append("|");
sb.append(r.NAME);
sb.append("|");
sb.append(r.LNG);
sb.append("|");
sb.append(r.LAT);
sb.append("|");
sb.append(r.ICON);
sb.append("|\n");
}
return sb.toString();
}
public table_list(int count) {
sequence = new RoadInfo[count];
for (int i = 0; i < count; i++) {
sequence[i] = new RoadInfo();
}
}
public RoadInfo[] sequence;
}
public class XMLTest {
/**
* @param args
*/
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
StringBuffer sb = new StringBuffer();
BufferedReader reader = new BufferedReader(new FileReader(new File(
"friend_msg.xml")));
while (true) {
String s = reader.readLine();// 读一行
if (s == null) {
break;
}
sb.append(s);
}
XStream xs = new XStream(new DomDriver());
table_list db = (table_list) xs.fromXML(sb.toString());
System.out.println(db.toString());
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有