Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

java read each lines in file

        BufferedReader br = null;
        try {
            File file = new File("myfile.txt"); // java.io.File
            FileReader fr = new FileReader(file); // java.io.FileReader
            br = new BufferedReader(fr); // java.io.BufferedReader
            String line;
            while ((line = br.readLine()) != null) {
              // process the line
            }
          }
          catch(IOException e) { e.printStackTrace();}
          finally
          {
              try { if (br != null) br.close(); }
              catch(IOException e) { e.printStackTrace(); }
          }
Source by stackabuse.com #
 
PREVIOUS NEXT
Tagged: #java #read #lines #file
ADD COMMENT
Topic
Name
2+2 =