Loading a text file into a textarea

后端 未结 4 429
猫巷女王i
猫巷女王i 2020-11-27 08:55

First of all, I am very basic at java. I am trying to browse a .txt file and load the contents of it, into the text area. I am completed the part, till which I receive the f

4条回答
  •  Happy的楠姐
    2020-11-27 09:07

    For indentation and line break you have to use "\n" before appending to to the text area..

      BufferedReader buff = null;
      try {
           buff = new BufferedReader(new FileReader(selFile));
           String str;
           while ((str = buff.readLine()) != null) {
           jtextArea.append("\n"+str);
       }
     } catch (IOException e) {
      } finally {
        try { in.close(); } catch (Exception ex) { }
        }
    

提交回复
热议问题