is string a Long number - Android java.util.regex

Android examples for java.util.regex:Number Pattern

Description

is string a Long number

Demo Code

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;
    }

}

Related Tutorials