Jessy Jessy - 22 days ago 7
Java Question

Reading and displaying data from a .txt file

How do you read and display data from .txt files?

Answer
BufferedReader in = new BufferedReader(new FileReader("<Filename>"));

Then, you can use in.readLine(); to read a single line at a time. To read until the end, write a while loop as such:

String line;
while((line = in.readLine()) != null)
{
    System.out.println(line);
}
in.close();