import java.io.Serializable;
import java.beans.*;
import java.io.*;
public class Test implements Serializable{
int prop;
public Test(){}
public Test(int prop){this.prop=prop;}
public int getProp(){return prop;}
public static void main(String[] args) {
Test o=new Test(123);
try {
XMLEncoder encoder=new XMLEncoder(new BufferedOutputStream(
new FileOutputStream("test.xml")));
String[]pName=new String[]{"prop"};
encoder.setPersistenceDelegate(Test.class,new DefaultPersistenceDelegate(pName));
encoder.writeObject(o);
encoder.close();
}catch (FileNotFoundException ex) {}
}
}
import java.beans.*;
import java.io.*;
public class Test implements Serializable{
int prop;
public Test(){}
public Test(int prop){this.prop=prop;}
public int getProp(){return prop;}
public static void main(String[] args) {
Test o=new Test(123);
try {
XMLEncoder encoder=new XMLEncoder(new BufferedOutputStream(
new FileOutputStream("test.xml")));
String[]pName=new String[]{"prop"};
encoder.setPersistenceDelegate(Test.class,new DefaultPersistenceDelegate(pName));
encoder.writeObject(o);
encoder.close();
}catch (FileNotFoundException ex) {}
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货