I'm doing a simple program, where it reads a .csv file (Excel) and then generates a graph of it. But I'm having trouble converting from String to Int. Below is the Button event code:
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
FileDialog abrir = new FileDialog(new Dialog(this),"Abrir arquivo",FileDialog.LOAD);
abrir.setVisible(true);
File arquivo = new File(abrir.getDirectory()+abrir.getFile());
XYSeries temp = new XYSeries("Temperatura");
try {
String linhaDoArquivo;
Scanner lerArquivo = new Scanner(arquivo);
while(lerArquivo.hasNext()){
linhaDoArquivo = lerArquivo.next();
String[] valores = linhaDoArquivo.split(",");
int instante = Integer.parseInt(valores[0]);
}
} catch (FileNotFoundException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
XYSeriesCollection dataset = new XYSeriesCollection();
dataset.addSeries(temp);
JFreeChart chart = ChartFactory.createXYLineChart("Temperatura", "Instante", "Temperatura", dataset, PlotOrientation.VERTICAL, true, true, false);
ChartPanel panel = new ChartPanel(chart);
jPanel1.removeAll();
jPanel1.add(panel, BorderLayout.CENTER);
jPanel1.validate();
}