let's say I have a line: "Hello Jason, How are you today?" inside a text file. And let's say I don't know what that line is, but I have one string from it, for example "are", and the word "are" is only showing in that line inside this text. How would I be able to find this place + delete the whole line without knowing the other words in the same line?
I've tried looking online for solutions, but I could only find solutions to my problem if I'd have known the whole line.
BufferedReader bufferedReader = new BufferedReader(new
FileReader("Hello.txt"));
String currentLine;
while((currentLine = bufferedReader.readLine()) != null){
if(currentLine.contains("are")){
//Delete the whole line.
}
}
Expected results: delete a line that contains a word. Errors: None.