new files
This commit is contained in:
parent
3af7344581
commit
86c034bb8b
1364 changed files with 21352 additions and 0 deletions
|
|
@ -0,0 +1,10 @@
|
|||
public boolean isNumeric(String input) {
|
||||
try {
|
||||
Integer.parseInt(input);
|
||||
return true;
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
// s is not numeric
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
private static final boolean isNumeric(final String s) {
|
||||
if (s == null || s.isEmpty()) return false;
|
||||
for (int x = 0; x < s.length(); x++) {
|
||||
final char c = s.charAt(x);
|
||||
if (x == 0 && (c == '-')) continue; // negative
|
||||
if ((c >= '0') && (c <= '9')) continue; // 0 - 9
|
||||
return false; // invalid
|
||||
}
|
||||
return true; // valid
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
public static boolean isNumeric(String inputData) {
|
||||
return inputData.matches("[-+]?\\d+(\\.\\d+)?");
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
public static boolean isNumeric(String inputData) {
|
||||
NumberFormat formatter = NumberFormat.getInstance();
|
||||
ParsePosition pos = new ParsePosition(0);
|
||||
formatter.parse(inputData, pos);
|
||||
return inputData.length() == pos.getIndex();
|
||||
}
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
public static boolean isNumeric(String inputData) {
|
||||
Scanner sc = new Scanner(inputData);
|
||||
return sc.hasNextInt();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue