Lab Exercise Eight
For this exercise you are to do the following:
Write a Java main class to read your program file as a data file (for example the name could be "src/LabExerciseEight.java" using the Scanner class. This is similar to Lab Exercise Five. Also see the ScannerTextFileWithTextAreaIO example.
Accumulate the "tokens" (pieces) returned by the Scanner class's next() method in a String out separated by the end-of-line.
After reading the file display out in a JTextArea in a JScrollPane in a JOptionPane.
Add to the program a call to the Scanner's useDelimiter("...") method so that the tokens returned are all characters between any number of blanks.
Change the String parameter to the useDelimiter method so that the tokens are all characters between any number of digits.
Change the String parameter to the useDelimiter method so that the tokens are any number of digits.
Write a second main class to read the data file ncaa2009.data The file has the following form:
year:winning team name:score:losing team name:score
An example is:
1995:UCLA:92:Florida International:56
Use the Scanner class to read the file and choose the String parameter to the useDelimiter method so that the tokens returned are just the team names i.e. ignore the year and the scores. Add each team to an ArrayList<String>. Make sure that each team is added only once (use the boolean contains(...) method or the int indexOf(...) method or of the ArrayList class).
After the file has been read accumulate the teams from the ArrayList<String> in a String variable out each separated by the end-of-line.
After reading the file display out in a JTextArea in a JScrollPane in a JOptionPane.