Write a method called collapseSpaces that accepts a Scanner representing an input file as its parameter, then

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 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!

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: