I keep getting a null pointer exception with this code:
It's suppose to load a text file into a textArea.
JFileChooser chooser = new JFileChooser();
int returnVal = chooser.showOpenDialog(this);
String getFile = chooser.getName();
if(returnVal == JFileChooser.APPROVE_OPTION)
{
try {
FileReader filegetter = new FileReader(getFile);
BufferedReader br = new BufferedReader(filegetter);
String line = br.readLine();
while ((line)!= null)
{
textArea2.setText(line);
}
}
catch (FileNotFoundException ex)
{
ex.printStackTrace();
}
catch (Exception myE)
{
myE.printStackTrace();
}
}