Here you can find the source of toInt(String intValue, int defaultValue)
public static int toInt(String intValue, int defaultValue)
//package com.java2s; /*************************************************************************** * Copyright (c) 2006 Eike Stepper, Fuggerstr. 39, 10777 Berlin, Germany. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * //from w ww . j a v a 2s.co m * Contributors: * Eike Stepper - initial API and implementation **************************************************************************/ public class Main { public static int toInt(String intValue, int defaultValue) { try { return Integer.valueOf(intValue).intValue(); } catch (Exception e) { return defaultValue; } } }