Hi,all
I serialize Object to byte[] and then use base64 encode.It works well
now,I need more test on unix server(now I tested on my pc,win
XP).btw,the web service client and server both run on unix server and
writen by java.
Thanks for your help.
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.i

bjectInputStream;
import java.i

bjectOutputStream;
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;
public class WSHelper {
static private BASE64Encoder encode = new BASE64Encoder();
static private BASE64Decoder decode = new BASE64Decoder();
static public String OToS(Object obj) {
long start=System.currentTimeMillis();
String out = null;
if (obj != null) {
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(obj);
out = encode.encode(baos.toByteArray());
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
long end=System.currentTimeMillis();
System.out.println("Encode:"+(end-start));
return out;
}
static public Object SToO(String str) {
long start=System.currentTimeMillis();
Object out = null;
if (str != null) {
try {
ByteArrayInputStream bios = new ByteArrayInputStream(decode
.decodeBuffer(str));
ObjectInputStream ois = new ObjectInputStream(bios);
out = ois.readObject();
} catch (IOException e) {
e.printStackTrace();
return null;
} catch (ClassNotFoundException e) {
e.printStackTrace();
return null;
}
}
long end=System.currentTimeMillis();
System.out.println("Decode:"+(end-start));
return out;
}
}