Android String to Int Convert convertStringToInt(String str)

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

Description

convert String To Int

Declaration

public static int convertStringToInt(String str) 

Method Source Code

//package com.java2s;

public class Main {

    public static int convertStringToInt(String str) {
        return convertStringToInt(str, 0);
    }// ww  w  .jav  a2s .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. stringToIntArray(String arrString, String separator)
  2. getIntegerArrayList(String strInput)
  3. validInt(CharSequence integer)
  4. parseIntOrZero(CharSequence charSequence)
  5. parseInt(String string, int defValue)
  6. convertStringToInt(String str, int failValue)