Question
IN JAVA Write a program that replaces each line of a file with its reverse. For example, if you run java Reverse HelloPrinter.java Create the
IN JAVA Write a program that replaces each line of a file with its reverse.
For example, if you run java Reverse HelloPrinter.java Create the output as HelloPrinterReverse.java. If the file HelloPrinter.java contains the text public class HelloPrinter { public static void main(String[] args) { // Display a greeting in the console window System.out.println("Hello, World!"); } } ?? then the contents are changed to retnirPolleH ssalc cilbup { )sgra ][gnirtS(niam diov citats cilbup { wodniw elosnoc eht ni gniteerg a yalpsiD // ;)"!dlroW ,olleH"(nltnirp.tuo.metsyS } } If there is a blank line in the input file, do not print it in the output file. If you run Reverse twice on the same file, you get back the original file.
Create the output file as HelloPointerOriginal.java java Reverse HelloPrinterReverse.java If the input file doesnt exist, throw the message Input file not found. Please check an rerun the program. Allow the user to enter the input file one more time. If the user enters an invalid file again, terminate the program. Use a try... catch statement.
Step 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