Olá Amigos , sou leigo em java e estou implementando um programa bem simples , mas que está dando erro ao concatenar as strings, já tentei resolver mas não consegui, alguém poderia me ajudar ? Obrigado!
Segue a parte do código:
for(int i=0; i<35; i++){
linha = MyIO.readLine();
tipoMetodo = linha.substring(0,1); // Pega o tipo do método a ser chamado
if (tipoMetodo.charAt(0) == 'I') {
if (tipoMetodo.charAt(1) == '*') {
posicao = Integer.parseInt(linha.substring(3,4));
id = Integer.parseInt(linha.substring(6,8));
}
else {
id = Integer.parseInt(linha.substring(3,5).trim());// Pega o id
}
// Se id for menor que 10 acrescenta dois zeros antes antes do id
if(id < 10){
int n = 00;
novoId = Integer.toString(n) + Integer.toString(id); //Acrescenta 00 antes do número, para o mesmo ficar com 3 digitos
} else if(id>9 && id<100){
int n = 0;
novoId = Integer.toString(n) + Integer.toString(id);
}else {
novoId = Integer.toString(id);
}
nome = ("/tmp/"+novoId+".html");
}
Os erros que deram foram estes:
java.lang.NumberFormatException: For input string: "/tmp/105.html" at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) at java.lang.Integer.parseInt(Integer.java:569) at java.lang.Integer.parseInt(Integer.java:615) at Principal.main(Principal.java:20)