Android String to Int Convert convertStringToInt(String str, int failValue)

Here you can find the source of convertStringToInt(String str, int failValue)

Description

convert String To Int

Declaration

public static int convertStringToInt(String str, int failValue) 

Method Source Code

//package com.java2s;

public class Main {

    public static int convertStringToInt(String str) {
        return convertStringToInt(str, 0);
    }/*from ww w  . j  a  v a 2  s .  c o m*/

    public static int convertStringToInt(String str, int failValue) {
        if (str == null) {
            return failValue;
        }
        try {
            return Integer.parseInt(str);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return failValue;
    }
}

Related

  1. getIntegerArrayList(String strInput)
  2. validInt(CharSequence integer)
  3. parseIntOrZero(CharSequence charSequence)
  4. parseInt(String string, int defValue)
  5. convertStringToInt(String str)