62,623
社区成员
发帖
与我相关
我的任务
分享package customXmlAdapter;
import java.io.Serializable;
public class TestBean implements Serializable{
private char[] chars;
private int id1;
private Integer id2;
public int getId1() {
return id1;
}
public void setId1(int id1) {
this.id1 = id1;
}
public Integer getId2() {
return id2;
}
public void setId2(Integer id2) {
this.id2 = id2;
}
public char[] getChars() {
return chars;
}
public void setChars(char[] chars) {
this.chars = chars;
}
}
public class m2 {
public static void main(String[] args)throws Exception {
TestBean testBean=new TestBean();
testBean.setId1(33);
testBean.setId2(2);
testBean.setChars("你好".toCharArray());
ByteArrayOutputStream bout=new ByteArrayOutputStream();
ObjectOutputStream out=new ObjectOutputStream(bout);
out.writeObject(testBean);
ByteArrayInputStream bin=new ByteArrayInputStream(bout.toByteArray());
ObjectInputStream in=new ObjectInputStream(bin);
Object obj=in.readObject();
System.out.println(obj);
}
}