Here you can find the source of formatInt(String value, int defaultValue)
public static int formatInt(String value, int defaultValue)
//package com.java2s; //License from project: Apache License public class Main { public static int formatInt(String value, int defaultValue) { try {//from w w w .j av a 2s. c o m if (isNotEmpty(value)) { return Integer.valueOf(value).intValue(); } else { return defaultValue; } } catch (Exception e) { return defaultValue; } } public static boolean isNotEmpty(String str) { return null != str && !str.trim().equals(""); } }