Loading a text file into a textarea

后端 未结 4 430
猫巷女王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条回答
  •  暖寄归人
    2020-11-27 09:25

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

提交回复
热议问题