Here you can find the source of toInt(String str)
public static int toInt(String str)
//package com.java2s; //License from project: Mozilla Public License public class Main { public static int toInt(String str) { return toInt(str, 0); }//from w w w. ja v a 2 s. c o m public static int toInt(String str, int defaultValue) { if (str == null) { return defaultValue; } try { return Integer.parseInt(str); } catch (NumberFormatException nfe) { return defaultValue; } } }