Android examples for java.lang:Integer
Parse string to Int with exception handler
import android.content.Context; import android.text.TextUtils; import android.util.Log; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.util.Locale; public class Main{ public static int toInt(String str, int defValue) { try {/*from w w w . j av a 2 s . co m*/ return Integer.parseInt(str); } catch (Exception e) { } return defValue; } }