/** * @param offset file pointer to start reading lines from * @param prefixArr prefix to search forward for * @return offset where the search found the first match or EOF * @throws IOException if an I/O exception occurs while searching */ public long search(long offset, char[] prefixArr) throws IOException { // debug // System.out.println(offset + " - " + prefix); String tmpStr; ffReadLine.seek(offset); if (offset > 0) { ffReadLine.readLine(); } while (true) { offset = ffReadLine.filePointer; tmpStr = ffReadLine.readLine(); if (tmpStr == null) { break; } if (psComparator.comparePrefix(prefixArr, tmpStr.toCharArray()) <= 0) { break; } } ffReadLine.reset(); return offset; }
/** * Read the next line at the current file pointer. * * @return next line at the current file pointer * @throws IOException if an I/O exception occurs while reading tne next line */ public String readLine() throws IOException { return ffReadLine.readLine(); }