Create a program search a text file of strings


Discussion:

Q: Create 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

 

Solution Preview :

Prepared by a verified Expert
JAVA Programming: Create a program search a text file of strings
Reference No:- TGS01935077

Now Priced at $20 (50% Discount)

Recommended (95%)

Rated (4.7/5)