Java Number Parse toNumber(String value, int defValue)

Here you can find the source of toNumber(String value, int defValue)

Description

Convenience method for converting a String into an Integer.

License

Open Source License

Declaration

static int toNumber(String value, int defValue) 

Method Source Code

//package com.java2s;
// See LICENSE.txt for license information

public class Main {
    /** Convenience method for converting a String into an Integer. */
    static int toNumber(String value, int defValue) {
        if (value != null) {
            try {
                return Integer.parseInt(value);
            } catch (NumberFormatException e) {
            }/*from  ww  w.  j  a v a 2s.  c om*/
        }
        return defValue;
    }
}

Related

  1. toNumber(String hash)
  2. toNumber(String num)
  3. toNumber(String s)
  4. toNumber(String string)
  5. toNumber(String text)
  6. toNumberArray(byte[] array)
  7. toNumberMatrix(byte[][] matrix)
  8. toNumberPassword(int length)
  9. toNumbers(char[] array_)