Convert data types
Posted: Fri Jun 20, 2003 1:51 pm
People.. help!!!!!
I'm having a little problem trying to convert String to int.
First I'm using a byte variable to read the input data.
byte data[ ] = new byte [3];
System.in.read (data);
Then I convert to String
String data_string = new String (data);
Then I convert to int
int data_int = Integer.parseInt(data_string)
Then appears a error , actually an exception <NumberFormatException>. If I use 'byte data[ ] = new byte[ 1 ]' doesn't make that error.
I don't know how to convert whitout making that exception.
Could someone help me please!
Thanx!
Trinity
I'm having a little problem trying to convert String to int.
First I'm using a byte variable to read the input data.
byte data[ ] = new byte [3];
System.in.read (data);
Then I convert to String
String data_string = new String (data);
Then I convert to int
int data_int = Integer.parseInt(data_string)
Then appears a error , actually an exception <NumberFormatException>. If I use 'byte data[ ] = new byte[ 1 ]' doesn't make that error.
I don't know how to convert whitout making that exception.
Could someone help me please!
Thanx!
Trinity