Share
Explore BrainMass

Java Reader Program

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. .

Attachments

Solution Summary

This solution provides guidelines on writing a Java program that will search a text file of strings representing int values and will organize numbers in chronological order.

$2.19