Write a program that will search a text file of strings


Write a program that will search a text file of strings representing numbers of type int and will write the largest and the smallest numbers to the screen. The file contains nothing but strings representing numbers of type int one per line. Your solution can use either the BufferedReader class or the Scanner class.

To read a file, you should do one of the following:

Construct a FileReader to access the file, then use the FileReader to construct a BufferedReader. or

Construct a FileInputStream with the file name, then construct a Scanner to parse the stream.

The readLine() method in BufferedReader will return null when the end of the file is reached.

If your solution uses Scanner instead of BufferedReader you will need to check the result of a method such as hasNextLine() or hasNextInt() to detect the end of file.

The Math class includes methods that can be used to compare int (and other numeric) values..

Attachment:- searchnumbers.txt

Solution Preview :

Prepared by a verified Expert
JAVA Programming: Write a program that will search a text file of strings
Reference No:- TGS01250520

Now Priced at $20 (50% Discount)

Recommended (98%)

Rated (4.3/5)