Java examples for java.lang:String Parse
Parse Integer from String with default value
//package com.java2s; public class Main { public static void main(String[] argv) throws Exception { String value = "java2s.com"; System.out.println(getInt(value)); }/*from w w w . java 2s . co m*/ public static Integer getInt(String value, Integer defaultValue) { try { return Integer.valueOf(value); } catch (Exception ex) { return defaultValue; } } public static Integer getInt(String value) { return getInt(value, null); } }