Java tutorial
//package com.java2s; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static boolean isPhoneNumber(String phoneNum) { if (isEmpty(phoneNum, true)) return false; Pattern pattern = Pattern.compile("^1\\d{10}$"); Matcher matcher = pattern.matcher(phoneNum.trim()); return matcher.matches(); } public static boolean isEmpty(String str) { return isEmpty(str, false); } public static boolean isEmpty(String str, boolean isTrim) { if (str == null) return true; if (isTrim) { return "".equals(str.trim()); } else { return "".equals(str); } } public static boolean isEmpty(String... params) { return isEmpty(false, params); } public static boolean isEmpty(boolean isTrim, String... params) { if (params == null || params.length == 0) return true; for (String param : params) { if (isEmpty(param, isTrim)) return true; } return false; } }