Question: Write a method called collapseSpaces that accepts a Scanner representing an input file as its parameter, then reads that file and outputs it with all

Write a method called collapseSpaces that accepts a Scanner representing an input file as its parameter, then reads that file and outputs it with all its tokens separated by single spaces, collapsing any sequences of multiple spaces into single spaces. For example, consider the following text:

many spaces on this line!

If this text were a line in the file, the same line should be output as follows:

many spaces on this line!

Step by Step Solution

3.48 Rating (171 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

public static void collapse Spaces Scanner input while ... View full answer

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 Building Java Programs A Back to Basics Approach Questions!