I am trying to remove a specific string in my text file. Current code gets the line one by one until 50 is hit. I am trying to remove the string (EXACT MATCH!) in the notepad, but not sure how to do so.
Scanner input = new Scanner(new File("C:\\file.txt"));
int counter = 0;
while(input.hasNextLine() && counter < 50) {
counter++;
String tempName = input.nextLine();
//perform my custom code here
//somehow delete tempName from the text file (exact match)
}
I have tried input.nextLine().replaceFirst(tempName, "");
without any luck