A classe não está excluindo, não sei porque
alguem pode me ajudar?
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.nio.file.Files;
import java.util.Scanner;
public class ExcluirArquivos {
public static void excluir(String path) throws IOException {
System.out.println("Nome da busca");
String nome = new Scanner(System.in).nextLine();
File file = new File(path);
File temp = new File("_temp_");
PrintWriter out = new PrintWriter(new FileWriter(temp));
Files.lines(file.toPath())
.filter(p -> !p.toLowerCase().contains(nome.toLowerCase()))
.forEach(out::println);
out.flush();
out.close();
temp.renameTo(file);
}
}