All pastes #330258 Raw Edit

Untitled

public javascript v1 · immutable
#330258 ·published 2007-01-27 19:15 UTC
rendered paste body
import java.io.*;import java.util.*;public class Driver {    /**     * @param args     */    public static void main(String[] args) {        Employees list = new Employees();        try {            /* add code here to open the input file called             * hrdb.txt and create a BufferedReader object.             * Next, use a while loop to read data from the             * file one line at a time.  Within the loop, use             * a StringTokenizer to break up the string input             * pieces.  Note that id, lastname, and firstname             * are strings and salary is an integer.  Next,             * use these four values to create a new Person             * object and try to call the list's addEmployee             * method.  Note the types of exceptions that this             * method might throw.  Remember also that creating             * a FileReader can throw a FileNotFoundException             * and creating a BufferedReader throws the more             * general IOException, a parent of BufferedReader.             *             */            BufferedReader in = new BufferedReader(new FileReader("hrdb.txt"));            String line = null;            while((line = in.readLine()) != null) {                /**                 * StringTokenizer is not very efficient, String.split is much                 * better :)                 */                StringTokenizer st = new StringTokenizer(line, ",");                Person p = new Person(                        while( st.hasMoreTokens() ) { st.nextToken() ; },                        while( st.hasMoreTokens() ) { st.nextToken() ; },                        while( st.hasMoreTokens() ) { st.nextToken() ; },//                      st.nextToken(),//                      st.nextToken(),   //                      st.nextToken(),                          Integer.parseInt(st.nextToken()));                list.addEmployee(p);            }        } catch (FileNotFoundException ex) {            System.err.println(ex);            System.exit(1);        } catch (IOException ex) {            System.err.println(ex);            System.exit(1);        } catch (DuplicateEmployeeException ex) {            ex.printStackTrace();        }        list.printEmployeeList();    }}