日期:2014-05-20  浏览次数:20696 次

SWING对象怎么转换为byte[]数组????
如题:

------解决方案--------------------
javax.swing.JPanel p = new javax.swing.JPanel();
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(p);
byte b[] = new byte[bos.size()];
b = bos.toByteArray();
System.out.println(java.util.Arrays.toString(b));
bos.close();
oos.close();