Android examples for java.util.regex:Number Pattern
is string a Long number
import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.util.Base64; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.net.URLDecoder; import java.net.URLEncoder; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main{ public static boolean isLong(String str) { if ("0".equals(str.trim())) { return true; }//from www . j a v a2s. co m Pattern pattern = Pattern.compile("^[^0]\\d*"); Matcher isNum = pattern.matcher(str); if (!isNum.matches()) { return false; } return true; } }