Here you can find the source of parseInteger(String inStr, Integer def)
public static Integer parseInteger(String inStr, Integer def)
//package com.java2s; //License from project: Apache License import java.util.regex.Pattern; public class Main { public static final String EMPTY = ""; public static Integer parseInteger(String inStr, Integer def) { if (isEmpty(inStr) || !isNumeric(inStr)) { return def; } else {/*from w ww . j av a2 s.c o m*/ return Integer.valueOf(inStr); } } public static Integer parseInteger(Object obj, Integer def) { return parseInteger(String.valueOf(obj), def); } public static boolean isEmpty(String inStr) { if (null == inStr || EMPTY.equals(inStr.trim())) { return true; } return false; } public static boolean isNumeric(String inStr) { if (null == inStr || EMPTY.equals(inStr.trim())) { return false; } Pattern pattern = Pattern.compile("[0-9]*"); return pattern.matcher(inStr).matches(); } public static boolean equals(CharSequence cs1, CharSequence cs2) { return cs1 == null ? cs2 == null : cs1.equals(cs2); } }