0
Personal greetings. I’m creating a program that reads data from a csv file. I’m having trouble reading a String and converting to int, because in the String reading is not removed the quotes ("").
Caused by: java.lang.NumberFormatException: For input string: ""5865""
expected value 5865
Down with my code:
public void carregarOriginado(FileUploadEvent event) throws IOException {
UploadedFile uploadedFile = event.getFile();
if (uploadedFile != null) {
Scanner scanner = new Scanner(uploadedFile.getInputstream(), "UTF-8");
scanner.nextLine();
while (scanner.hasNext()) {
String linha = scanner.nextLine();
String[] values = linha.split(";");
originado.setDiaEvento(getData());
originado.setCalledcountry(values[1]);
originado.setCalledoperator(values[2]);
if (values[3].contains("BICS")){
originado.setCollednode("BICS");
}
if (values[3].contains("MEO")){
originado.setCollednode("PT");
}
originado.setLastcause(values[4]);
originado.setCount(Integer.parseInt(values[5]));
originadoFacade.create(originado);
}
}
FacesContext context = FacesContext.getCurrentInstance();
context.addMessage(null, new FacesMessage("Sucesso", "Ficheiro Carregado Com Sucesso"));
criarPerformance();
}