text: public static boolean indexExists(Directory directory) throws IOException {String[] files = directory.listAll();String prefix = IndexFileNames.SEGMENTS + "_";for(String file : files) {if (file.startsWith(prefix)) {return true;}}return false;}