Dear all,
Does anyone know how to rewrite the following code to read all the words from a text file since I've run it and it only reads the last line. I want to avoid using Lists since I have no knowlegde of how to use them in the code.
Code:
............
..........
try
{
br = new BufferedReader(new FileReader(args[0]));
}
catch (FileNotFoundException fnfe)
{
System.out.println("Error opening file '" + args[0] + "'. " +"Please omit .txt extension.");
System.exit(3);
}
boolean finish = false;
String input = null;
String[] array=null;
//read lines until end of file is reached
while (!finish)
{
try
{
input = br.readLine();
}
catch(IOException ioe)
{
System.out.println("I/O error");
System.exit(2);
}
//end of file?
if (input==null)
{
finish=true;
}
else
{
array = input.split("\\s+");
}
}
Thanks in advance!