public void findPackageAndClass() throws IOException {
  packageName=null;
  className=null;
  LineNumberReader reader=new LineNumberReader(new FileReader(inputFile));
  try {
    while (className == null || packageName == null) {
      String line=reader.readLine();
      if (line == null)       break;
      if (packageName == null) {
        Matcher matcher=PACKAGE_PATTERN.matcher(line);
        if (matcher.find()) {
          packageName=matcher.group(1);
        }
      }
      if (className == null) {
        Matcher matcher=CLASS_PATTERN.matcher(line);
        if (matcher.find()) {
          className=matcher.group(1);
        }
      }
    }
    if (className == null) {
      className="Yylex";
    }
  }
  finally {
    reader.close();
  }
}

public void findPackageAndClass ( ) throws IOException { packageName = null ; className = null ; LineNumberReader reader = new LineNumberReader ( new FileReader ( inputFile ) ) ; try { while ( className == null || packageName == null ) { String line = reader . readLine ( ) ; if ( line == null ) break ; if ( packageName == null ) { Matcher matcher = PACKAGE_PATTERN . matcher ( line ) ; if ( matcher . find ( ) ) { packageName = matcher . group ( 1 ) ; } } if ( className == null ) { Matcher matcher = CLASS_PATTERN . matcher ( line ) ; if ( matcher . find ( ) ) { className = matcher . group ( 1 ) ; } } } if ( className == null ) { className = "Yylex" ; } } finally { reader . close ( ) ; } }
peek into . flex file to get package and class name
