public static boolean pattern(String args) { Pattern pattern = Pattern.compile("^[-+]?(([0-9]+)([.]([0-9]+))?|([.]([0-9]+))?)$"); Matcher isNum = pattern.matcher(args); return !isNum.matches()?false:true;}