EncodeTest.java
Dosyayı İndir
package com.godoro.bean;
import java.beans.*;
import java.io.*;
public class EncodeTest {
public static void main(String[] args) throws IOException {
String path="C:\\Godoro\\Research\\BeanXmlEncoding\\test\\MyBean.xml";
FileOutputStream fos=new FileOutputStream(path);
BufferedOutputStream bos=new BufferedOutputStream(fos);
XMLEncoder encoder=new XMLEncoder(bos);
MyBean bean1=new MyBean();
bean1.setMyId(111);
bean1.setMyDouble(100.5);
bean1.setMyString("Birinci Metin");
bean1.setBytes(new byte[]{1,2,3,4,5});
bean1.setMyBaseId(99111);
bean1.setMyBaseDouble(99100.5);
bean1.setMyBaseString("XXXBirinci Metin");
encoder.writeObject(bean1);
encoder.flush();
MyBean bean2=new MyBean();
bean2.setMyId(222);
bean2.setMyDouble(200.5);
bean2.setMyString("İkinci Metin");
bean1.setBytes(new byte[]{11,22,33,44,56});
bean2.setMyId(999222);
bean2.setMyDouble(99200.5);
bean2.setMyString("XXXİkinci Metin");
encoder.writeObject(bean2);
encoder.flush();
encoder.close();
}
}
Dosyayı İndir