Read from a Text File
You can use FileReader and BufferedReader to read in a text file. You
must import java.io.*; (You can also use the Scanner class)
Example:
try
{
FileReader fr = new FileReader("somefilename.txt");
BufferedReader br = new BufferedReader(fr);
String line = null;
while ((line = br.readLine()) != null)
{
// process this line
}
br.close();
}
catch (IOException e1)
{
System.out.println("Error reading in Data");
}
catch (Exception e2)
{
System.out.println("Error reading in Data");
}