// 身份证验证 public static boolean isSFZ(String str) { try { if (str.length() != 18) { return false; } String[] array = { "1", "0", "x", "9", "8", "7", "6", "5", "4", "3", "2" }; int sum = 0; int count = 17; for (int i = 0; i < str.length() - 1; i++) { int a = Integer.parseInt("" + str.charAt(i)); sum += a * Math.pow(2, count); count--; } return (str.charAt(str.length() - 1) + "") .equalsIgnoreCase(array[sum % 11]); } catch (Exception e) { return false; } }