Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

reading in lines from a file java

private ArrayList<String> readFileLines(String filepath) throws FileNotFoundException, IOException{
  File fp = new File(filepath);
  FileReader fr = new FileReader(fp);
  BufferedReader br = new BufferedReader(fr);

  ArrayList<String> lines = new ArrayList<>();
  String line;
  while((line = br.readLine()) != null) { lines.add(line); }

  fr.close();
  return lines;
}
 
PREVIOUS NEXT
Tagged: #reading #lines #file #java
ADD COMMENT
Topic
Name
9+9 =