Text file:
32|Chan|2019-11-29|14:12:01.346
Code:
DefaultListModel<String> listModel;
public LogActivity() {
initComponents();
LoginInfo login = new LoginInfo();
try {
FileReader fr = new FileReader(login.getLogoutRecord());
BufferedReader br = new BufferedReader(fr);
String read = br.readLine();
while(read != null)
{
listModel.addElement(read);//add data to list model object
}
logoutList.setModel(listModel);//store listmodel to logoutlist object
} catch (FileNotFoundException ex) {
Logger.getLogger(LogActivity.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(LogActivity.class.getName()).log(Level.SEVERE, null, ex);
}
}
I'm trying to display my text file into a Jlist
, but I keep on getting this exception.
Error: Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException