好像有个
getbyte
之类的方法。

解决方案 »

  1.   

    getByte怎么用呀?
    那是一个完整的对象,如何转换成byte呀?
    我发现ObjectOutputStream和ByteArrayOutputStream都是从OutputStream扩展的,但是我无法在将ByteArrayOutputStream写入到FileInputStream。
    我真的很差,不要笑我。我该怎么做呀?
      

  2.   

    document是一个对象,我如何把它转换为byte呢?
    最后我还要把它写入文件,我用
    FileOutputStream fstrm = new FileOutputStream(f);
    ByteArrayOutputStream bout = new ByteArrayOutputStream(fstrm);
    ObjectOutputStream ostrm = new ObjectOutputStream(bout);
    好像不行。
    那如何将ByteArrayOutputStream 写入文件呢?
    谢谢!
      

  3.   

    看错误的提示好象是你写如的东西不可序列化的错误
    难道是Document对象现在不可序列化了吗
    你可一这样试试
    ostrm.writeObject(textPane);
    或者你可以只写如英文,不写中文看看有没有错
      

  4.   

    只有英文的话,一点问题都没有。即使插入图片也没有问题。
    如果,使用JDK1.3.0就都没有问题(不需重新编译)
    难道是JDK把序列化重写了。
    那要怎么做才能真正的支持中文呢?
    是不是要对内容编码定义为Unicode,如何做呀!
    谢谢!
      

  5.   

    谢谢lianyunzxp(小刀):
    ostrm.writeObject(textPane);
    的方法没有报错。但文件读进来后,就是不正常显示。
    我修改后的,代码有错吗?
    写文件:
    FileOutputStream fstrm = new FileOutputStream(f);
    BufferedOutputStream bout = new BufferedOutputStream(fstrm);
    ObjectOutputStream ostrm = new ObjectOutputStream(bout);
    Object o = (Object)textPane;
    ostrm.writeObject(o);
    ostrm.flush();
    fstrm.flush();
    读文件:
    FileInputStream fin = new FileInputStream(f);
    BufferedInputStream bin = new BufferedInputStream(fin);
    ObjectInputStream istrm = new ObjectInputStream(bin);
    JTextPane jtp =(JTextPane) istrm.readObject();
    if(textPane.getDocument() != null)
      textPane = jtp;
    validate();
      

  6.   

    bug,见http://developer.java.sun.com/developer/bugParade/bugs/4513615.html,好像没有什么简单的解决方法。