gist JS

Tuesday, February 08, 2005

xml-rpc that handles serialized java objects / $$$

Sorry if this doesn't do it for you, but writing this made my day.

* @author dwyer
* Who says xml-rpc can't pass java objects?
* just serialize, stream to byte[] rinse, and repeat.
public class Utils {

public static byte[] byteArrayFromObj(java.io.Serializable obj){
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = null;
oos = new ObjectOutputStream(bos);
}catch(IOException e){
return null;
return bos.toByteArray();

public static Object objFromByteArray(byte[] ba){
ByteArrayInputStream bis = null;
ObjectInputStream ois = null;
Object rtn = null;
bis = new ByteArrayInputStream(ba);
ois = new ObjectInputStream(bis);
rtn = ois.readObject();
}catch(IOException e){
System.out.println("io except");
return null;
}catch(ClassNotFoundException e){
System.out.println("c not found");
return null;
return rtn;

These Tiff commentaries are actually pretty fun to read. Go 'team that must not be named'!

No comments: