Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Marketing Database Analytics

Authors: Andrew D. Banasiewicz

1st Edition

0415657881, 978-0415657884

More Books

Students also viewed these Databases questions