JAVA中有这种函数可以来计算序列化后对象的实际大小么(以KB或者字节计算),
还是要用外部辅助工具来截数据包~

解决方案 »

  1.   

    是通过ObjectIn(Out)putStream来传输,知道大小不难吧
      

  2.   

    //一个实现序列化接口的对象MM
    MM m=new MM();ObjectOutputStream out=new ObjectOutputStream(new FileOutputStream("xxxx.file"));
    out.writeObject(xx);
    out.close();File f = new File("xxxx.file");
      if (f.exists()) {
              FileInputStream fis = null;
        try {
    fis = new FileInputStream(f);
    } catch (FileNotFoundException e) {
    e.printStackTrace();
    }     try {
    System.out.println("File has " + (double)((double)fis.available()/1000)
      + "KB");
    } catch (IOException e) {
    e.printStackTrace();
    }
      

  3.   

    ByteArrauOutputStream中有toByteArray方法