The FileWriter is a constructor with two parameters. Of course the name of the file an a boolean. If the boolean is set to true you can append new entries to your file. Nevertheless the variable of the BufferedWriter must also append any new content to the file. Make sure to implement both!

Remember this snippet scan.nextLine(); to input spaces also which means writing line by line. The so called lineSeperator is nothing else but a paragraph.

It's no big thing anymore to declare an integer for counting each character of the file. Since each character is read out anyway, they only need to be added within the while loop. But you must place the snippet coun += spac.length(); on the first position of the block.

Do not forget the condition if the file is missing! If you adress a file which doesn't exist the program is going to search endlessly.

The website uses cookies!