- Where Developers Learn, Share, & Build Careers


I'm curious about what the most effective way to read the text file (do not worry about size, it's quite a lot Is java.io OK) and then put its contents in the display for a JTextArea .

e.g. Can I completely consume any file in a string and then use it to display JTextArea.setText or I should read lines from line or byte arrays and give them stringbuffers Should be populated in and then setting the text area that

You can use and pass it. Just do this:

Java 7 - Attempt-processing block

  (file reader reader = new file reader ("myfile.txt ")) {TextArea.read (Reader, blank); }   

Java 6 - try-end block

  FileReader reader = null; Try {Reader = new FileReader ("myfile.txt"); TextArea.read (reader, tap); } Finally {if (reader! = Null) {reader.close (); }}    

Comments

Popular posts from this blog

java - NullPointerException for a 2d Array -

python - Assemble mpeg file unable to play in mediaplayer -

c# - NameSpace Manager or XsltContent to parse aspx page -