OK, I currently have the follwoing:
The code should read from the file stock.txt and put the info into the array in the prog (arrays already declared etc) however i just get nullpointer errors and non displaying of the data in the file.
Could anyone offer any help i.e. have I made any really obvious mistakes?
File stockFile = new File("stock.txt");
if (!stockFile.exists())
{
return;
}
BufferedReader input=
new BufferedReader(
new FileReader(stockFile));
int count=1;
stockCode[count] = input.readLine();
stockDesc[count] = input.readLine();
String strCurrentLevel = input.readLine();
currentLevel[count] = Integer.parseInt(strCurrentLevel);
String strReorderLevel = input.readLine();
reorderLevel[count] = Integer.parseInt(strReorderLevel);
String strPrice = input.readLine();
price[count] = Float.parseFloat(strPrice);
while (stockCode!=null)
{
System.out.print("\t"+stockCode[count]);
System.out.print("\t\t"+stockDesc[count]);
System.out.print("\t\t"+currentLevel[count]);
System.out.print("\t\t"+reorderLevel[count]);
System.out.print("\t\t"+price[count]);
count++;
stockCode[count] = input.readLine();
stockDesc[count] = input.readLine();
strCurrentLevel = input.readLine();
currentLevel[count] = Integer.parseInt(strCurrentLevel);
strReorderLevel = input.readLine();
reorderLevel[count] = Integer.parseInt(strReorderLevel);
strPrice = input.readLine();
price[count] = Float.parseFloat(strPrice);
}
input.close();
Thanks in advance