Assignment 9 - Due Wednesday March 31 23:59 by
e-mail
File I/O and Sorting
Study the Text Analyzer presented in your text on page 344 (case study
13.1
). Then write a program (Homework9.java
)
that
- has a similar GUI, featuring:
- a
Label
- a
TextField
- a
Button
- and a
TextArea
and which
- reads a file that contains an unspecified number
of integer values,
- sorts them in ascending order, and
- outputs them in the GUI's
TextArea
field.
Notes:
- You can use any sorted method you want. Selection sort (also called
exchange sort) was mentioned in class as the simplest method (it appears
on page 194 in the textbook). But you can use bubble sort or quicksort or
another sorting method that you prefer.
- Make sure you account for the unknown number of integers in the file.
In class we mentioned that using a
Vector
to store the integers
is a flexible way of reading the numbers in from the file. If you use arrays
make sure you can accommodate any file size without taking up more memory
than you need. So using Vector
s is encouraged.
- The example program uses
StreamTokenizer
. The behavior of
the objects of this class is similar to StringTokenizer
s. These
kind of objects are fully customizable but we will use them in their default
setting, in which the delimiters are space, newline,
tab, and carriage return.
- We will grade these programs by running them on various test files that
will be created with text editors.