Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In JAVA Create a new java class named LabFive Add a main method. Add code in the main that will: a. Check to see if
In JAVA
Create a new java class named LabFive Add a main method. Add code in the main that will: a. Check to see if there are two command line arguments. i. The first argument will be the name of the file that the class will create. ii. The second argument will be a message. This message has to be one word with no spaces. b. If there aren't two arguments then the method will output: "Please enter two arguments on the command line, a file name and a message" and terminate. c. If there are two arguments, then the method will instantiate an instance of the LabFive class and call its run method. The two arguments will be passed to the run method. Add a method. a. The method will have a void return type. b. The method will have two String parameters. The first parameter will be the name of output file. The second parameter will be a message. Add code in the run method that will: a. Open a file for writing using its first parameter as the file path. b. Write the message parameter to the output file. c. Close the output file. d. Include full exception handling. The class must pass the lab 5 tests. Verify you can run the class. a. Pass in a file name and a message. Then, manually verify that the file was properly written with the message. b. Verify your error handling, too! What happens if you do not pass in the proper number of command line arguments? Capture screenshots of: - The command line output showing all unit tests passing. - The command line output when running your program's "happy path" and the output file that is created. - The command line output demonstrating the error handling in your program. Name the screenshot/s using the lab number. Create a new java class named LabFive Add a main method. Add code in the main that will: a. Check to see if there are two command line arguments. i. The first argument will be the name of the file that the class will create. ii. The second argument will be a message. This message has to be one word with no spaces. b. If there aren't two arguments then the method will output: "Please enter two arguments on the command line, a file name and a message" and terminate. c. If there are two arguments, then the method will instantiate an instance of the LabFive class and call its run method. The two arguments will be passed to the run method. Add a method. a. The method will have a void return type. b. The method will have two String parameters. The first parameter will be the name of output file. The second parameter will be a message. Add code in the run method that will: a. Open a file for writing using its first parameter as the file path. b. Write the message parameter to the output file. c. Close the output file. d. Include full exception handling. The class must pass the lab 5 tests. Verify you can run the class. a. Pass in a file name and a message. Then, manually verify that the file was properly written with the message. b. Verify your error handling, too! What happens if you do not pass in the proper number of command line arguments? Capture screenshots of: - The command line output showing all unit tests passing. - The command line output when running your program's "happy path" and the output file that is created. - The command line output demonstrating the error handling in your program. Name the screenshot/s using the lab numberStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started