Purchase Solution

Java Reader Program

Not what you're looking for?

Ask Custom Question

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

Purchase this Solution

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.

Purchase this Solution


Free BrainMass Quizzes
Basic Computer Terms

We use many basic terms like bit, pixel in our usual conversations about computers. Are we aware of what these mean? This little quiz is an attempt towards discovering that.

Java loops

This quiz checks your knowledge of for and while loops in Java. For and while loops are essential building blocks for all Java programs. Having a solid understanding of these constructs is critical for success in programming Java.

C++ Operators

This quiz tests a student's knowledge about C++ operators.

Basic Networking Questions

This quiz consists of some basic networking questions.

Inserting and deleting in a linked list

This quiz tests your understanding of how to insert and delete elements in a linked list. Understanding of the use of linked lists, and the related performance aspects, is an important fundamental skill of computer science data structures.