Here you can find the source of tryParseInt(String str, int defaultValue)
public static int tryParseInt(String str, int defaultValue)
//package com.java2s; /**/*from w ww .j a v a 2 s .c o m*/ * Copyright (c) 2012 Todoroo Inc * * See the file "LICENSE" for the full license governing this code. */ public class Main { /** * Tries to parse an int from a string, returning the default value on failure */ public static int tryParseInt(String str, int defaultValue) { try { return Integer.parseInt(str); } catch (NumberFormatException e) { return defaultValue; } } }