Java Integer Create toInteger(String value, int defaultValue)

Here you can find the source of toInteger(String value, int defaultValue)

Description

to Integer

License

Open Source License

Declaration

public static int toInteger(String value, int defaultValue) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static int toInteger(String value) {
        return toInteger(value, 0);
    }/*from   www  .j  av  a 2s . c o m*/

    public static int toInteger(String value, int defaultValue) {

        int valueAsInt = 0;

        try {
            valueAsInt = Integer.parseInt(value);
        } catch (NumberFormatException e) {
            return defaultValue;
        }

        return valueAsInt;
    }
}

Related

  1. toInteger(String value)
  2. toInteger(String value)
  3. toInteger(String value)
  4. toInteger(String value)
  5. toInteger(String value, int _default)
  6. toInteger(String value, int defaultValue)
  7. toInteger(String value, Integer defValue)
  8. toInteger(String[] s)
  9. toInteger(String[] source)