Question
File Processing Complete the class code below and write a static method named reverseLines that accepts a Scanner containing an input file as a parameter
File Processing
Complete the class code below and write a static method named reverseLines that accepts a Scanner containing an input file as a parameter and that echoes the input file to System.out with each line of text reversed. For example, given the following input file:
If this method works properly,
the lines of text in this file
will be reversed.
Remember that some lines might be blank.
Your method should print the following output:
,ylreporp skrow dohtem siht fI
elif siht ni txet fo senil eht
.desrever eb lliw
.knalb eb thgim senil emos taht rebmemeR
Note: some of the input lines can be blank lines.
public class ReverseLines {
public static void main(String[] args)
{
Scanner fileIn = new Scanner(new File("story.txt"));
reverseLines(fileIn);
}
} // end of ReverseLines class
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