Converting a String to int is easy but this can raise NumberFormatException exception. Following method can be used for the subject purpose:

Java Code:
public static int stringToInt(String string) throws NumberFormatException{
    return Integer.parseInt(string);
}