I'm currently developing a basic function that deletes specific customer entries from a txt file, currently the code I do have only searches for the customer's name and deletes only the name. How do I change this so it deletes all of the customers information as opposed to just their name from the txt file?
Customer data within the txt file is formatted in this manner:
Dave Ted
10 Roberts Drive
12345
1000
B&Q £23.72, Úber £13.50, Eleanor Humphries £78.21
Mike Valencia
9 Farrels Way
56789
100
Cineworld £20.00, TGI £39.30, RadioShack £60.19
method from the code
public static void removeCus()throws IOException{
Scanner stdin = new Scanner( System.in);
String name,address,id,balance,transactions,record;;
File inputFile = new File("text_files/customers.txt");
File tempFile = new File("text_files/tempFile.txt");
BufferedReader br = new BufferedReader(new FileReader(inputFile));
BufferedWriter bw = new BufferedWriter(new FileWriter(tempFile));
System.out.println("Enter the Customers name: ");
name = stdin.nextLine();
while( ( record = br.readLine() ) != null ) {
if( record.contains(name) )
continue;
bw.write(record);
bw.flush();
bw.newLine();
}
br.close();
bw.close();
inputFile.delete();
tempFile.renameTo(inputFile);
boolean successful = tempFile.renameTo(inputFile);
}