String Tokenizer hanging at run-time
//Creating the object array and reading values into it
try{
String fileName = "BOBSDB.txt";
//connect the stream tokeniser to the file
FileInputStream stream = new FileInputStream(fileName);
InputStreamReader iStreamReader = new InputStreamReader(stream);
BufferedReader bufReader = new BufferedReader(iStreamReader);
StreamTokenizer reader = new StreamTokenizer(bufReader);
try{
BookList1729731[] BookList = new BookList1729731[10];
int arrayCounter = 0, readerCounter = 0, isbn = 0, numInStock = 0;
String title = "";
float price = 0;
reader.nextToken();
while(reader.ttype != StreamTokenizer.TT_EOF){
while(reader.ttype != StreamTokenizer.TT_EOL){
switch(readerCounter){
case 0:
isbn = (int)reader.nval;
break;
case 1:
title = reader.sval;
break;
case 2:
numInStock = (int)reader.nval;
break;
case 3:
price = (float)reader.nval;
break;
}
readerCounter ++;
}
BookList[arrayCounter] = new BookList1729731(isbn, title, numInStock, price);
readerCounter = 0;
arrayCounter ++;
}
}
catch(IOException e){
JOptionPane.showMessageDialog(null, "error in file input:" + e);
}
}
catch(IOException e){
JOptionPane.showMessageDialog(null, "error in opening file for input:" + e);
}
The code compiles fine but when I run the program it hangs. If this section of the code is commented out it opens fine so it must be here somewhere.
Stu

