Posted By:
J_Greene
Posted On:
Wednesday, June 19, 2002 09:31 AM
Hi... I've just started playing with the java.beans.XMLEncoder/Decoder in the JDK 1.4 . I have an object that has a StringBuffer as an attribute. Everything else is writting - but that is not. I get the StringBuffer definition - but not the value in the string buffer. Pretty sure it is something simple that I'm doing wrong. Below is my sample code. Can someone give me a clue as to what I've missed? Thanks import java.io.*; import java.beans.XMLEncoder; import java.beans.XMLDecoder; import javax.swing.*; public class h { int _one = 0;
More>>
Hi... I've just started playing with the java.beans.XMLEncoder/Decoder in the
JDK 1.4 . I have an object that has a StringBuffer as an attribute.
Everything else is writting - but that is not. I get the StringBuffer
definition - but not the value in the string buffer.
Pretty sure it is something simple that I'm doing wrong.
Below is my sample code. Can someone give me a clue as to what I've missed?
Thanks
import java.io.*;
import java.beans.XMLEncoder;
import java.beans.XMLDecoder;
import javax.swing.*;
public class h {
int _one = 0;
String _hi = null;
StringBuffer _hello = null;
public h() {
}
public h(int one, String hi, StringBuffer hello) {
setOne(one);
setHi(hi);
setHello(hello);
}
public int getOne() { return _one; } ;
public void setOne(int o) { _one = o; } ;
public String getHi() { return _hi; } ;
public void setHi(String s) { _hi = s; } ;
public StringBuffer getHello() { return _hello; } ;
public void setHello(StringBuffer s) { _hello = s; } ;
public static void main(String[] f) {
h tempObj = new h(1, "hi",new StringBuffer("Hello"));
try {
XMLEncoder e = new XMLEncoder(
new BufferedOutputStream(
new FileOutputStream("h.xml")));
e.writeObject(tempObj);
e.close();
} catch (Throwable t) {
t.printStackTrace();
}
}
}
<<Less