Question: Create a new java class named ReadingTestLab and a txt file with some text. 1. Add a main method. 2. Add code in the main

Create a new java class named ReadingTestLab and a txt file with some text.

1. Add a main method.

2. Add code in the main method that will:

- Check to see if there is one command line argument.

- If there is not just one argument then the method will output: Please enter one argument on the command line and terminate.

- If there is one command line argument then the method will call the run method and pass the argument.

3. Add a method named run.

- The method will have a void return type.

- The method will have one String parameter.

4. Add code in the run method that will:

- Open the input file that was passed as a parameter and output the full contents to the terminal window. To accomplish this the method will need to:

- Open the input file.

- Loop through the lines of the input file.

- Output each line.

- Close the input file after the loop has run.

- Include full exception handling.

The class must pass the lab 4 tests.

Verify the class runs properly.

Pass in a file name that exists and verify the file was properly read and displayed.

Verify your error handling, too! What happens if you do not pass in file name? What if you pass in a file name that does not exist?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!