Rode o exemplo.
É isso que ele faz.
A primeira linha do txt é o cabeçalho da tabela.
Veja o código da função onLerDoCVS():
[code] protected void onLerDoCVS()
{
JFileChooser chooser = getChooser();
if (chooser.showOpenDialog(this) != JFileChooser.APPROVE_OPTION)
return;
try
{
BufferedReader reader = null;
try
{
reader = new BufferedReader(new FileReader(
chooser.getSelectedFile()));
//Leitura do cabeçalho
String line = reader.readLine();
if (line == null)
throw new RuntimeException(
"O arquivo não tem linhas suficientes para ser exibido!");
//Criamos nosso model com o cabeçalho
//O split separa as colunas.
CVSTableModel model = new CVSTableModel(line.split(","));
//Leitura das linhas
line = reader.readLine();
while (line != null)
{
model.add(line); // Cada linha lida entra no model
line = reader.readLine();
}
//Definimos nosso model na table.
getTblTabela().setModel(model);
}
finally
{
//É necessário finalizar os recursos.
//Garantimos isso num finally.
if (reader != null)
reader.close();
}
}
catch (Exception e)
{
JOptionPane.showMessageDialog(this, e.getMessage());
}
}[/code]