SynonymIndexBuilder { public boolean deleteIndexFromFS(String path) { File folder = new File(path); if (!folder.exists()) { return true; } if (folder.isDirectory()) { File[] filelist = folder.listFiles(); if (filelist.length == 0) { if (!folder.delete()) { error.set(false, Messages.getString("SynonymIndexBuilder.couldNotDelete", folder.getAbsolutePath())); return false; } } else { boolean allDeleted = true; for (File f : filelist) { if (!f.delete() && allDeleted) { allDeleted = false; } } if (allDeleted && !folder.delete()) { allDeleted = false; } if (!allDeleted) { error.set(false, Messages.getString("SynonymIndexBuilder.couldNotDelete", folder.getAbsolutePath())); return false; } } } else { error.set(false, Messages.getString("SynonymIndexBuilder.pathIsFile", folder.getAbsolutePath())); return false; } return true; } SynonymIndexBuilder(); Error getError(); void setSynonymSeparator(char synonymSeparator); void initIndexInFS(String path); boolean insertDocument(String word, String synonyms); boolean insertDocumentIfNotExists(String word, String synonyms); int updateDocument(String word, String synonyms); int deleteDocumentByWord(String word); void deleteAllDocuments(); int addSynonymToDocument(String word, String newSynonym); int removeSynonymFromDocument(String word, String synonymToDelete); boolean deleteIndexFromFS(String path); void closeIndex(); void commit(); Analyzer getAnalyzer(); int getNumDocs();  }
@Test public void deleteIndexFromFS() throws IOException { printLineToConsole("\n---------------Test deleteIndexFromFS----------"); String indexPath = "data/index2"; SynonymIndexBuilder synonymIndexBuilder = new SynonymIndexBuilder(); synonymIndexBuilder.initIndexInFS(indexPath); File indexfile = new File(indexPath); assertEquals(true, indexfile.exists()); synonymIndexBuilder.insertDocument("salut", "toto"); synonymIndexBuilder.commit(); synonymIndexBuilder.closeIndex(); synonymIndexBuilder.deleteIndexFromFS(indexPath); assertEquals(false, indexfile.exists()); }