Answers for "write to text file line by line java"

7

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;
}
Posted by: Guest on March-28-2020
0

how to write a line in java

\n Text\r\n
Posted by: Guest on September-07-2021

Code answers related to "write to text file line by line java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language