/* XMLTest.Java
* Created on 2004-11-16
*/
package test;
import java.beans.XMLEncoder;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
public class XMLTest {
public void xmlEncode() throws Exception
{
MyInfo my = new MyInfo();
my.setMyAge(25);
my.setMyName("Google");
my.setMyAddress("china");
my.setMyEdUCation("master in science");
XMLEncoder encoder = new XMLEncoder(
new BufferedOutputStream(
new FileOutputStream("myinfo.xml")));
encoder.writeObject(my);
encoder.close();
System.out.println(my);
}
public void xmlDecode() throws Exception
{
java.beans.XMLDecoder decoder = new java.beans.XMLDecoder(
new BufferedInputStream(new FileInputStream("myinfo.xml")));