Here is a class with methods to handle text files using java read text files, write text files, read line by line, write data to text files etc.
This class can be directly copied and pasted in your framework with required adjustments at designated places.