1) Scan the file line by line, and write the results in another temporary file.If you encounter the String within a line, remove it, and write only the modified line.
2) Remove the intial file, and rename the temporary file with the name of the initial file.
In order to achieve this, take a look at the File class.
File file = new File("data.txt");
Then "scan" the file using the Scanner class, as in the following example:
Scanner scanner = new Scanner(file);
while (scanner.hasNextLine()) {
String line = scanner.nextLine();
/* Proccess line */
}
To write information into a new File, take a look at PrintWriter class.
LATER EDIT:
If you feel confortable with the concept of buffers, you can also use BufferedReader with its read function, in order to process bigger chunks of data, instead of "lines".