Question: Write a Java program that edits a text input file for extra blanks. This program will replace any string of 2 or more blanks with
Write a Java program that edits a text input file for extra blanks. This program will replace any string of 2 or more blanks with a single blank.
It should work as follows:
Create a temporary file.
Copy from the input file to the temporary file but do not copy extra blanks.
Copy the contents of the temporary file back into the original file.
Use a method or methods of the File class to remove the temporary file.
You will want to use the File class for other things in your program. The temporary file should have a name that is different from all existing files so that the existing files are not affected (except for the file being edited). The program will ask the user for the file path name of the file to be edited. However, it will not ask the user for the name of the temporary file but instead will generate the name within the program. The name can be generated any way you like. One possible way to generate this temporary file is to start with an unlikely name, such as TempX.txt, and to append a character, such as X, until a name is found that does not name an existing file.
The input file must be on the path - C:\\CS163\\
Your program has to preserve the input files line and paragraph structure, e.g., the resulting file cannot be a single line. Use comments in the code
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
