protected String nextToken() throws IOException, CatalogException {
  String token="";
  int ch, nextch;
  if (!tokenStack.empty()) {
    return (String)tokenStack.pop();
  }
  while (true) {
    ch=catfile.read();
    while (ch <= ' ') {
      ch=catfile.read();
      if (ch < 0) {
        return null;
      }
    }
    nextch=catfile.read();
    if (nextch < 0) {
      return null;
    }
    if (ch == '-' && nextch == '-') {
      ch=' ';
      nextch=nextChar();
      while ((ch != '-' || nextch != '-') && nextch > 0) {
        ch=nextch;
        nextch=nextChar();
      }
      if (nextch < 0) {
        throw new CatalogException(CatalogException.UNENDED_COMMENT,"Unterminated comment in catalog file; EOF treated as end-of-comment.");
      }
    }
 else {
      stack[++top]=nextch;
      stack[++top]=ch;
      break;
    }
  }
  ch=nextChar();
  if (ch == '"' || ch == '\'') {
    int quote=ch;
    while ((ch=nextChar()) != quote) {
      char[] chararr=new char[1];
      chararr[0]=(char)ch;
      String s=new String(chararr);
      token=token.concat(s);
    }
    return token;
  }
 else {
    while (ch > ' ') {
      nextch=nextChar();
      if (ch == '-' && nextch == '-') {
        stack[++top]=ch;
        stack[++top]=nextch;
        return token;
      }
 else {
        char[] chararr=new char[1];
        chararr[0]=(char)ch;
        String s=new String(chararr);
        token=token.concat(s);
        ch=nextch;
      }
    }
    return token;
  }
}

protected String nextToken ( ) throws IOException , CatalogException { String token = "" ; int ch , nextch ; if ( ! tokenStack . empty ( ) ) { return ( String ) tokenStack . pop ( ) ; } while ( true ) { ch = catfile . read ( ) ; while ( ch <= ' ' ) { ch = catfile . read ( ) ; if ( ch < 0 ) { return null ; } } nextch = catfile . read ( ) ; if ( nextch < 0 ) { return null ; } if ( ch == '-' && nextch == '-' ) { ch = ' ' ; nextch = nextChar ( ) ; while ( ( ch != '-' || nextch != '-' ) && nextch > 0 ) { ch = nextch ; nextch = nextChar ( ) ; } if ( nextch < 0 ) { throw new CatalogException ( CatalogException . UNENDED_COMMENT , "Unterminated comment in catalog file; EOF treated as end-of-comment." ) ; } } else { stack [ ++ top ] = nextch ; stack [ ++ top ] = ch ; break ; } } ch = nextChar ( ) ; if ( ch == '"' || ch == '\'' ) { int quote = ch ; while ( ( ch = nextChar ( ) ) != quote ) { char [ ] chararr = new char [ 1 ] ; chararr [ 0 ] = ( char ) ch ; String s = new String ( chararr ) ; token = token . concat ( s ) ; } return token ; } else { while ( ch > ' ' ) { nextch = nextChar ( ) ; if ( ch == '-' && nextch == '-' ) { stack [ ++ top ] = ch ; stack [ ++ top ] = nextch ; return token ; } else { char [ ] chararr = new char [ 1 ] ; chararr [ 0 ] = ( char ) ch ; String s = new String ( chararr ) ; token = token . concat ( s ) ; ch = nextch ; } } return token ; } }
return the next token in the catalog file . < p / > < p > fyi : this code does not throw any sort of exception for a file that contains an n
