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

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!