Exemplo n.º 1
0
  /**
   * Reads a line of text. The line of text is passed to the parseText method where it is parsed and
   * a Resource object is returned. The Resource object is then added to the list. When a null is
   * read from the Resource file the method terminates and returns the list to the caller. A list
   * that points to null is an empty list.
   *
   * @param inputFile
   * @return The list of drivers
   */
  public ResourceList readResourceListFromFile(String inputFile) {

    String text; // Line of text from the file
    boolean done; // End of the file - stop processing

    // New resorce list object - this will contain all of the resources in
    // the file

    ResourceList listObject = new ResourceList();

    if (openFile(inputFile)) {

      done = false;

      while (!done) {

        try {

          text = readLineOfText();

          if (text == null) {

            done = true;

          } else {

            listObject.addResource(parseText(text));
          } // if

        } // try
        catch (Exception Error) {

          return (null);
        } // catch
      } // while

    } else {

      return (null);
    } // if

    return (listObject);
  } // readTeacherListFromFile