void (@NotNull Path directory) { try (DirectoryStream<Path> stream = Files.newDirectoryStream(directory)) { stream.forEach(path -> { if (!path.getFileName().toString().equals(LOCK_FILE_NAME)) { try { NioFiles.deleteRecursively(path); } catch (IOException e) { System.err.println("Failed to delete " + path + ": " + e); } } }); } catch (IOException e) { System.err.println("Failed to clean directory " + directory + ": " + e); } }