Hi everyone....
I want to develop a music lexicon (tyoe band name --> give description) and I want to add terms (bandName and description)
I use ArrayList but I want to change. I have also the code that read a text file (bands.txt) but I dont know haw it works...
Any suggestion?
private void addTerms ()
{
addTerm("Anathema","A music band from Liverpool, UK.");
}
import java.io.*;
public class ReadFile
{
public static void main(String[] args)
{
try
{
//Sets up a file reader to read the file passed on the command line one character at a time
FileReader input = new FileReader("bands.txt");
//Filter FileReader through a Buffered read to read a line at a time
BufferedReader bufRead = new BufferedReader(input);
String line; // String that holds current file line
int count = 0; // Line number of count
while((line = bufRead.readLine()) != null){
System.out.println(count+": "+line);
line = bufRead.readLine();
count++
}
bufRead.close();
}
catch (ArrayIndexOutOfBoundsException e){
/* If no file was passed on the command line, this expception is
generated. A message indicating how to the class should be
called is displayed */
System.out.println("Usage: java ReadFile filename\n");
}catch (IOException e){
// If another exception is generated, print a stack trace
e.printStackTrace();
}
}
}