我认为jEditorPane似乎是针对Html的,如果说编辑txt文件,你还不如直接用JTextArea!
然后通过流写入文件!

解决方案 »

  1.   

    读文件:BufferedReader fs = new BufferedReader(new FileReader(new File("Filename.txt")));
    写文件:
    DataOutputStream out = new  DataOutputStream(
                                    new BufferedOutputStream(
                                      new FileOutputStream("Filename.txt",true)));  
    out.writeBytes("asdf");
    out.close();
      

  2.   

    我按上面的方法写了,但是执行到new FileOutputStream("Filename.txt",true)))时,系统提示:java.io.FileNotFoundException: E: est est.txt (文件名、目录名或卷标语法不正确。)
    好像是文件名不对。我把代码写出来,帮忙看一下: void jButton2_actionPerformed(ActionEvent e) {
           try {
                DataOutputStream out = new  DataOutputStream(
                                        new BufferedOutputStream(
                                          new FileOutputStream("E:\test\test.txt",true)));
                out.writeBytes("this is a test");
                out.close();
            }
            catch(Exception ex) {
              ex.printStackTrace();
            }  }