Here you can find the source of deleteIndexBeforeStart(String basePath)
public static void deleteIndexBeforeStart(String basePath)
//package com.java2s; //License from project: Apache License import java.io.*; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; public class Main { public static void deleteIndexBeforeStart(String basePath) { try {/*from w ww.j ava 2 s .c o m*/ Path path = Paths.get(basePath); boolean exists = Files.exists(path); boolean directory = Files.isDirectory(path); if (exists && directory) { File file = new File(basePath); delete(file); } } catch (IOException e) { System.out.println("Impossible to delete index path"); System.exit(0); } } private static void delete(File file) throws IOException { if (file.isDirectory()) { for (File c : file.listFiles()) { delete(c); } } if (!file.delete()) { throw new FileNotFoundException("Failed to delete file: " + file); } } }