Here you can find the source of toInt(String value, Integer defaultValue)
public static Integer toInt(String value, Integer defaultValue)
//package com.java2s; //License from project: Open Source License public class Main { public static Integer toInt(String value, Integer defaultValue) { if (isEmpty(value)) return defaultValue; try {// w ww. j ava 2 s. c o m return Integer.parseInt(value); } catch (Exception e) { return defaultValue; } } public static boolean isEmpty(String str) { if (str == null) return true; if ("".equals(str.trim())) return true; return false; } }