Java String Parse tryParse(String val, int defaultValue)

Here you can find the source of tryParse(String val, int defaultValue)

Description

try Parse

License

Apache License

Declaration

public static int tryParse(String val, int defaultValue) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static int tryParse(String val, int defaultValue) {
        int v = defaultValue;
        try {/*from  ww w.  j ava2  s.  com*/
            v = Integer.parseInt(val);
        } catch (Exception e) {
        }

        return v;
    }
}

Related

  1. tryParse(String input, Object defVal)
  2. tryParse(String pValue)
  3. tryParse(String s, double d)
  4. tryParse(String s, int i)
  5. tryParse(String s, Integer defaultValue)
  6. tryParseToType(Object object, Class clazz)
  7. TryParseUShort(String str, short[] u)