I'm trying to teach myself Java and I'm having a problem reading from a random
access file. There is too much code to paste here so hopefully the limited
amount I supply will be enough. What I'm trying to do is read all the records
from the file and display them in a TextArea. The problem is when I try
to get the data from the class I get a NullPointerException. I'm not sure
why since I create a new version of the class. Thanks for you help in advance.

private void readRecords()
{
Record record = new Record();

DecimalFormat twoDigits = new DecimalFormat( "0.00" );

try{
recordDisplay.setText("The records are:\n");

while(true){
record.read(file);

record = (Record) input.readObject();

if (String.valueOf(record.getRecord()) == " ")
{
recordDisplay.append(record.getRecord() +
"\t" +
record.getTool() +
"\t" +
record.getQuantity() +
"\t" +
record.getCost() +
"\n");
}
}
}
catch(EOFException eofex)
{
//do nothing
}
catch(Exception e)
{
JOptionPane.showMessageDialog(this,
"Error " + e,
"Error",
JOptionPane.ERROR_MESSAGE );
}

}//end readRecords