Explore BrainMass

Explore BrainMass

    Java Reader Program

    This content was COPIED from BrainMass.com - View the original, and get the already-completed solution here!

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

    © BrainMass Inc. brainmass.com October 9, 2019, 9:17 pm ad1c9bdddf


    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.