I have seen many people struggling with Reading files and writing files in java, also a great problem is how to edit a file too.
So in this code snippet I have put all these problems into one small program in hopes to help others. So this code snippet will ask for the name of a file, it will then read it in fully, after reading it will ask you to type in the contents of the line you would like to edit, it will then ask you for the replacement text. This will then be edited with new data by replacing the old, the old file will be deleted and then all will be written back to a new file.
Hope its helps people and now hopefully there will be less questions on how to read and write to a file and editing data within a file :) comments on the code are welcome, but before everyone complains that i used the scanner class to read in a file i did provide the other method too, why you may ask? well i wanted a short easy to grasp method to read files.
Edited by peter_budo: Updating code