I'm working with files, but I get two errors
For input string: "Eduardo" java.lang.NumberFormatException: For input string: "Eduardo"
before that I was throwing a NoSuchElementException error but I already solved it
This is my code to upload the file
public void cargar_txt(){
File ruta = new File(ruta_txt);
String linea = null;
int ln = 0;
try{
FileReader fr = new FileReader(ruta);
BufferedReader br = new BufferedReader(fr);
dc = null;
while((linea = br.readLine()) != null){
ln++;
try{
StringTokenizer st = new StringTokenizer(linea, ", ");
while(st.hasMoreElements() && st.nextToken() != null){
dc = new DatosCliente();
dc.setCuenta(Integer.parseInt(st.nextToken()));
dc.setNombre(st.nextToken());
dc.setPaterno(st.nextToken());
dc.setMaterno(st.nextToken());
dc.setSaldo(Double.parseDouble(st.nextToken()));
dc.setPassword(st.nextToken());
pb.AgregarCliente(dc);
}
}catch(NoSuchElementException ex){
System.out.println(String.format("NSE in %d: %s", ln, linea));
}
}
br.close();
}
catch(Exception e){
mensaje("Error al cargar el archivo: " + e.getMessage());
mensaje("Error: " + e);
System.out.println(e.getMessage());
System.out.println(e);
}
}