> Write a static method name wordCountAndFixSpace that takes a Scanner representing a file as a parameter and that reports

Write a static method name wordCountAndFixSpace that takes a Scanner representing a file as a parameter and that reports

Posted at: 2014-12-18 
his looks like homework...shouldn't you be asking for help rather than asking someone to do it for you? it's really not that difficult...write a static method that iterates through each byte of the file and determines what (char) it represents, then say have a spaces counter, if you encounter a space do spaces++; if the next byte is a space then spaces will equal 2 in which case you'll delete the second space otherwise you'll set spaces to 0. next you'll say if the byte is a ? or " or . or - or \n or \t just keep going. obviously with each character you'll add one to charactercount or you could just read the whole file into an byte array and after you cycle out the extra spaces do a variableofbytearrayname.length() but whatever.

Write a static method name wordCountAndFixSpace that takes a Scanner representing a file as a parameter and that reports various statistics about the file. The method should generate the number of lines, the total number of words (regard "can't" as 1-word and disregard any marks or signs such as ?, ", ., -, \n, \t, etc. when counting), the total number of characters, and the longest word. The text may contain multiple spaces and tabs. Those spaces should be reduced to single spaces between each word in order to print them to the console. Your program can assume that the text file may contain at least one line of input.

The input file contains the following text:

"Writing is an exercise."

You get better and faster with practice.

If you were going to run a marathon a year from now,

would you wait for months and then run 26 miles cold?

No, you would build up slowly, running most days.

You might start on the flats and work up to more

demanding and difficult terrain. To become a writer, write.

Don't wait for that book manuscript or that monster external-review report

to work on your writing.