hello,
how to add text file input into jTable .
I have one text file all.txt,
in this I store some IP values one by one.
i need to add the IP values into jTable IP Address column. how can I do it. any example is there.
my code is,
public void ListDisplay ()
{
IPList.setModel(jList2model);
try {
FileInputStream fis = new FileInputStream("Devices/all.txt");
BufferedReader br = new BufferedReader(new InputStreamReader(fis));
String line = null;
Vector data = new Vector();
line = br.readLine();
// while ( (line = br.readLine()) != null)
/// {
row.addElement(line);
// row.addElement(ipText.getText()+"-"+nameText.getText());
row.addElement((String)" ");
row.addElement((String) "");
row.addElement((String) "");
row.addElement((String) "");
row.addElement((String) "");
// tableModel.addRow(row);
rows.add(row);
nmsTable.addNotify();
// jList2model.add(jList2model.getSize() ,line);
// }
br.close();
}
catch (Exception ee) {}
}
I am using the default data model and store the rows and clums in that data model.
rows=new Vector();
colNames = new Vector();
String[] columnNames = {"IP Address","Status"};
addColumns(columnNames);
tableModel=new DefaultTableModel(rows,colNames);
nmsTable.setModel(tableModel);
but, I am able to store the IP Addresses from the table to all.txt file.
but, i can't able to retrieve and display it in the jtable.
whats my problem