public static void replaceTabs(int tabLength, StringBuffer s) {
        int index, col;
        StringBuffer whitespace;
        while ((index = s.indexOf("\t")) != -1) {
            whitespace = new StringBuffer();
            col = index;
            do {
                whitespace.append(" ");
                col++;
            } while ((col%tabLength) != 0);
            s.replace(index, index+1, whitespace.toString());
        }
    }