当前位置: 代码迷 >> J2SE >> SWING对象如何转换为byte[]数组?
  详细解决方案

SWING对象如何转换为byte[]数组?

热度:54   发布时间:2016-04-24 15:03:15.0
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();