public void buildIndexes(final File folder) throws FileNotFoundException,
    UnsupportedEncodingException, IOException {
        docNumber = folder.list().length;
        for (final File fileEntry : folder.listFiles()) {
            if (fileEntry.isDirectory()) {
                buildIndexes(fileEntry);
                docNumber += fileEntry.list().length;
            } else {
                docIdList.add(fileEntry.getName());
                BufferedReader in = new BufferedReader(new InputStreamReader(
                        new FileInputStream(fileEntry.getAbsoluteFile()), "UTF-8"));
                String content = new Scanner(in).useDelimiter("\\Z").next();

                String body = content.substring(content.indexOf("<body>")+6,
                        content.indexOf("</body>"));
                body = body.replaceAll("</v><v>", " ");
                body = body.replaceAll("\\<.*?\\>", "");
                body = body.replaceAll("\n", " ");
                body = body.replaceAll("[\\W]|_", " ");

                String[] line = body.split(" ");
                for (int j = 0; j < line.length; j++) {
                    this.addToInvertIndex(line[j], FREE_DOC_ID);
                    this.addToShiftIndex(line[j]);
                    this.addTokGramIndex(line[j]);
                    this.binTree.insert(binTree.getRootNode(), line[j]);
                }
                FREE_DOC_ID++;   
            }
        }
    }