public static boolean isNumber(final String num){
  if (num == null || num.length() == 0) {
    return false;
  }
  final boolean firstIsDigit=Character.isDigit(num.charAt(0));
  if (!firstIsDigit && num.charAt(0) != '-') {
    return false;
  }
  boolean dig=firstIsDigit;
  for (int i=1; i < num.length(); i++) {
    if (!Character.isDigit(num.charAt(i))) {
      return false;
    }
    dig=true;
  }
  return dig;
}

public static boolean isNumber ( final String num ) { if ( num == null || num . length ( ) == 0 ) { return false ; } final boolean firstIsDigit = Character . isDigit ( num . charAt ( 0 ) ) ; if ( ! firstIsDigit && num . charAt ( 0 ) != '-' ) { return false ; } boolean dig = firstIsDigit ; for ( int i = 1 ; i < num . length ( ) ; i ++ ) { if ( ! Character . isDigit ( num . charAt ( i ) ) ) { return false ; } dig = true ; } return dig ; }
check that a string is a number .
