-
You may choose to design your own applet that reads file data from
the web server host and uses it in an application. This should either use
the StreamTokenizer class on both word and number token types, or otherwise
make use of individual characters or tokens in the file. That is, it's
not o.k. to just use a readLine method from something like the BufferedReader
class to display the contents of the file without a significant computation
or display of individual data items from the file.
-
or try the following applet:
Books/Authors Search
This applet will make use of data from some files containing book titles
and authors. These files actually came from the coreJava CD:
Books.txt,
Authors.txt,
and
BooksAuthors.txt,
where
the last file connects an author to each book by relating the author id
to the book ISBN number. For this assignment, we can just ignore the publisher
information (but if you really want it, there is also a file of publishers:
Publishers.txt,
The applet should reads the contents of the file into a set of arrays,
Then there should be an interface where either the user can search for
books, either by typing in a key word which your applet uses to search
for in a title, or by typing in an author last name, which your applet
uses to search for. (You don't have to implement both, just one.) Then
the applet should display all the books that match the search.
Now in reading the files into a set of arrays, you can set it up in
various ways using streams. Also, you may wish to delete the first two
lines of each file which describe the file structure or make other edits
on the files to make your Java code easier. Here are two suggestions:
-
Use the StreamTokenizer class to read word and number tokens from the file.
In this case, you could replace the "|" separators between fields with
" | ", so that the tokenizer uses the blanks to find the "|" as a token.
Note that the book title will consist of several word tokens that you can
catenate back together. For an example using the StreamTokenizer class,
see the
Grocery File example.
-
Use a BufferedReader to read each line of the file into a String. Then
you can use various string methods, such as subString to separate out the
fields from each line.
Please document and submit your programs with a description as usual.