Very simple with a Regex
private static boolean isNumeric(String str){ return str != null && str.matches("[0-9.]+"); }