Answers for "how to read from text file in java"

6

java read file text

try(BufferedReader br = new BufferedReader(new FileReader("file.txt"))) {
    StringBuilder sb = new StringBuilder();
    String line = br.readLine();

    while (line != null) {
        sb.append(line);
        sb.append(System.lineSeparator());
        line = br.readLine();
    }
    String everything = sb.toString();
}
Posted by: Guest on March-12-2020

Code answers related to "how to read from text file in java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language