Here you can find the source of parseInteger(String str)
public static int parseInteger(String str)
//package com.java2s; //License from project: Apache License import java.util.regex.Pattern; public class Main { private static final Pattern INT_PATTERN = Pattern.compile("^\\d+$"); public static int parseInteger(String str) { return !isInteger(str) ? 0 : Integer.parseInt(str); }//from www. j a va 2 s . c o m public static boolean isInteger(String str) { return str != null && str.length() != 0 ? INT_PATTERN.matcher(str) .matches() : false; } }