//Johnny A. Shaieb //lab1b.java //Code to read strings from a file and print them to the //console in the same order // NOTE: there are bugs including the types causing compilation // errors and possibly an infinite loop. import java.io.*; import java.util.*; public class lab1b { public static void main(String args[]) { lab1b tl = new lab1b(); } //end main String inputString; Vector stringVector; long startTime, endTime, totalTime; public lab1b() { startTime = System.currentTimeMillis(); readFile(); outfile(); endTime = System.currentTimeMillis(); totalTime = endTime - startTime; System.out.println("total time taken: " + totalTime + " milliseconds"); } public void readFile() { try { BufferedReader br1 = new BufferedReader(new FileReader("C:\\Johnny\\School\\cs2003\\lab1\\lab1b.dat")); stringVector = new Vector(); StringTokenizer line; while ((inputString = br1.readLine()) != null) { line = new StringTokenizer(inputString); while(line.hasMoreTokens()) { stringVector.addElement(line.nextToken()); // } } br1.close(); } catch (IOException e) { System.out.println("IOException in reading input file!!!"); } } //end readFile() public void outfile() { int index=0; while(index