I am getting an ASCII value and I want to convert it into an integer because I know it\'s an Integer ASCII value.
int a=53;
This is an ASC
If you're sure that it is an int, you can just use Integer.parseInt();
Use Integer.parseInt(String)
or if it is only a single character use: int n = (int) (_char - '0')
If you can guarantee the string contains an integer:
Integer.parseInt(String)
Use:
try
{
int i = Integer.parseInt(StringValue);
}
catch (NumberFormatException nfe)
{
System.out.println("NumberFormatException: " + nfe.getMessage());
}
int yourInt = Integer.parseInt(yourString);
http://www.cse.wustl.edu/~kjg/java/api/java/lang/Integer.html#parseInt%28java.lang.String%29
int asciiValue = 53;
int numericValue = Character.getNumericValue(asciiValue);
System.out.println(numericValue);