Olá, estou começando
Estou tentando gerar um programa que abra somente arquivos .csv e adicione os dados em uma matriz
Matriz[linhas][colunas].
Porem está dando erro
private void AbrirActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
//cria um filtro para arquivos abrir somente arquivos *.csv
escarquivo.setFileFilter(new javax.swing.filechooser.FileFilter() {
@Override
public boolean accept(File file) {
return file.getName().toLowerCase().endsWith(".csv") || file.isDirectory();
}
@Override
public String getDescription() {
return "Aquivo Texto (.csv)";
}
});
Pts = 0;//Numero de pontos
int returVal = escarquivo.showOpenDialog(this);
if (returVal==JFileChooser.APPROVE_OPTION){
File file = escarquivo.getSelectedFile();
String nome = escarquivo.getName(file);
jLabel1.setText(nome);
try (FileReader reader = new FileReader(file)) {
BufferedReader input = new BufferedReader(reader);
String linha;
linha = input.readLine();
while(linha != null){
linha = input.readLine();
Pts+=1;
int IniCol=1;
Atributo = 0;
if (linha.length()>1){
for (int i=1;i<=linha.length();i++){
if((",".equals(linha.substring(i)))||(";".equals(linha.substring(i)))){
Atributo+=1;
IniCol = i+IniCol;
String coluna = linha.substring(IniCol, (i-IniCol));
dadosl[Pts][Atributo]= Double.parseDouble(coluna);
}
}
}
}
}
catch (IOException ioe) {
System.out.println(ioe);
}
jLabel2.setText(Integer.toString(Pts));
jLabel3.setText(Integer.toString(Atributo));
}
}
Desde já agradeço