Hi, so my problem is I don't know how to read more than one line from a text file.
say I have string.txt
and it contains:
Hello
Java
Hello
World
Welcome
how am I going to read every line of the string.txt? I tried using FileReader and BufferedReader but it only reads the first line using readLine(). And it should work even if I add more lines in the txt file.
Here's what I have so far..
public void readData ()
{
try
{
FileReader dataIn = new FileReader ("string.txt");
BufferedReader buffDataIn = new BufferedReader (dataIn);
while (true)
{
words = buffDataIn.readLine ();
if (words == null)
break;
}
c.println ("The current strings in the files are \"" + words + "\"");
}
catch (IOException e)
{
new Message ("Error");
}
}