Here you can find the source of isIDCard(String str)
public static boolean isIDCard(String str)
//package com.java2s; public class Main { public static boolean isIDCard(String str) { int length = str.length(); return isNumber(str) && (length == 15 || length == 18); }//from www.jav a 2 s . co m public static boolean isNumber(String str) { try { Integer.parseInt(str); return true; } catch (Exception e) { return false; } } }