public static long findNumber(String str,int offset) throws TagException {
  if (str == null) {
    throw new NullPointerException("String is null");
  }
  if ((offset < 0) || (offset >= str.length())) {
    throw new IndexOutOfBoundsException("Offset to image string is out of bounds: offset = " + offset + ", string.length()"+ str.length());
  }
  int i;
  int j;
  long num;
  i=offset;
  while (i < str.length()) {
    if (((str.charAt(i) >= '0') && (str.charAt(i) <= '9')) || (str.charAt(i) == '-')) {
      break;
    }
    i++;
  }
  j=i + 1;
  while (j < str.length()) {
    if (((str.charAt(j) < '0') || (str.charAt(j) > '9'))) {
      break;
    }
    j++;
  }
  if ((j <= str.length()) && (j > i)) {
    num=Long.parseLong(str.substring(i,j));
  }
 else {
    throw new TagException("Unable to find integer in string: " + str);
  }
  return num;
}

public static long findNumber ( String str , int offset ) throws TagException { if ( str == null ) { throw new NullPointerException ( "String is null" ) ; } if ( ( offset < 0 ) || ( offset >= str . length ( ) ) ) { throw new IndexOutOfBoundsException ( "Offset to image string is out of bounds: offset = " + offset + ", string.length()" + str . length ( ) ) ; } int i ; int j ; long num ; i = offset ; while ( i < str . length ( ) ) { if ( ( ( str . charAt ( i ) >= '0' ) && ( str . charAt ( i ) <= '9' ) ) || ( str . charAt ( i ) == '-' ) ) { break ; } i ++ ; } j = i + 1 ; while ( j < str . length ( ) ) { if ( ( ( str . charAt ( j ) < '0' ) || ( str . charAt ( j ) > '9' ) ) ) { break ; } j ++ ; } if ( ( j <= str . length ( ) ) && ( j > i ) ) { num = Long . parseLong ( str . substring ( i , j ) ) ; } else { throw new TagException ( "Unable to find integer in string: " + str ) ; } return num ; }
find the first whole number that can be parsed from the string
