i have problem reading the data from text file. The first line in my text file should go to 1st row but it go to the column, here is my code.
JScrollPane scrollPane_1 = new JScrollPane();
scrollPane_1.setBounds(30, 288, 944, 207);
frmDevelopNewProgram.getContentPane().add(scrollPane_1);
String[] columns={"Program Code","Program Name" ,"Major","Abbreviation"};
lap_table = new JTable();
scrollPane_1.setViewportView(lap_table);
DefaultTableModel tableModel;
// specify number of columns
tableModel = new DefaultTableModel(0,0);
tableModel.setColumnIdentifiers(columns);
lap_table.setModel(tableModel);
String line;
//BufferedReader reader;
try{
FileInputStream fis = new FileInputStream("C:\\Users\\Alex Ting\\workspace\\gui\\src\\Files\\output.txt");
BufferedReader br = new BufferedReader(new InputStreamReader(fis));
StringTokenizer st1 = new StringTokenizer(br.readLine(), "___");
while (st1.hasMoreTokens())
tableModel.addColumn(st1.nextToken());
while((line = br.readLine()) != null)
{
//tableModel.addColumn(line.split("___"));
tableModel.addRow(line.split(","));
}
br.close();
}
catch(IOException e){
JOptionPane.showMessageDialog(null, "Error");
e.printStackTrace();
}