public static void main(String[] args) {String path ="/path/to/your/file.txt"Path pathPng = Paths.get(path);deletePng(pathPng,originalFilename);}public void deletePng(Path dir, String fileNameToDelete) {log.info("开始执行删除数据逻辑");try {Files.walk(dir).filter(path -> path.toFile().isFile()).filter(path -> path.getFileName().toString().equals(fileNameToDelete)).forEach(path -> {try {Files.delete(path);log.info("删除图片成功目录:{},图片地址:{}", dir, fileNameToDelete);} catch (IOException e) {log.error("删除图片失败目录:{},图片地址:{}", dir, fileNameToDelete);}});} catch (IOException e) {log.error("删除图片异常:{}", e);}}