Here you can find the source of toInt(String text, int defaultValue)
public static int toInt(String text, int defaultValue)
//package com.java2s; //License from project: Apache License public class Main { public static int toInt(String text, int defaultValue) { if (text == null || text.isEmpty()) { return defaultValue; }/*w w w. j a va 2s . c o m*/ int ret; try { ret = (int) Double.parseDouble(text); } catch (Exception e) { return defaultValue; } return ret; } }