Monkkey05 de Octubre del 2005
Preguntapublic class TestNumeros {
int numero = 0;
StringBuffer st = new StringBuffer("");
char c;
public int lee() throws IOException
{
c = (char)System.in.read();
while (c != 'n')
{
st.append(c);
c = (char)System.in.read();
System.out.print(c);
}
numero = Integer.parseInt(st.toString());
return numero;
}
CONSOLA:
1111
111
Exception in thread "main" java.lang.NumberFormatException: For input string: "1111
"
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at Practica2.TestNumeros.lee(TestNumeros.java:18)
at Practica2.TestNumeros.main(TestNumeros.java:24)
int numero = 0;
StringBuffer st = new StringBuffer("");
char c;
public int lee() throws IOException
{
c = (char)System.in.read();
while (c != 'n')
{
st.append(c);
c = (char)System.in.read();
System.out.print(c);
}
numero = Integer.parseInt(st.toString());
return numero;
}
CONSOLA:
1111
111
Exception in thread "main" java.lang.NumberFormatException: For input string: "1111
"
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at Practica2.TestNumeros.lee(TestNumeros.java:18)
at Practica2.TestNumeros.main(TestNumeros.java:24)
