private byte[] objtobytearray(IPinfo gotobj, byte[] key) {
//gotobj是一個IPinfo object
  ByteArrayOutputStream buffers = new ByteArrayOutputStream();
  try {
   ObjectOutputStream out = new ObjectOutputStream(buffers);
   out.writeObject(gotobj);
   out.flush();
   out.close();
   //out close之前要加flush
  } catch (Exception e) {
   System.out.println("error");
  }
                byte[] guarddataarray = new byte[buffers.toByteArray().length];
  System.out.println("the data length length:"+guarddataarray.length);
  System.out.println("the key length length:"+key.length);
  if (guardflag)
   guarddataarray = guard.AES_Data_Encrypter(buffers.toByteArray(),
     key);
  else
   guarddataarray = buffers.toByteArray();
  return guarddataarray;
 }
2013年5月14日
[JAVA] 傳送object發生 java.io.StreamCorruptedException
訂閱:
張貼留言 (Atom)
 
沒有留言:
張貼留言