Here you can find the source of toInt(String s, int defaultInt)
public static int toInt(String s, int defaultInt)
//package com.java2s; //License from project: Open Source License public class Main { /**/*from www . j a v a2 s .c o m*/ * A quick an easy way to convert a String into a number, while catching * the NumberFormatException and returning a default number if the String is invalid */ public static int toInt(String s, int defaultInt) { try { return Integer.parseInt(s); } catch (NumberFormatException ex) { return defaultInt; } } }