@Override
    public List<LanguageResult> detectAll() {
        Language[] langs = detector.predictLanguages(buffer.toString());
        List<LanguageResult> results = new ArrayList<>();
        for (Language lang : langs) {
            LanguageResult r =
                    new LanguageResult(lang.getLang(), getConfidence(lang.getConfidence()),
                            (float) lang.getConfidence());
            results.add(r);
        }
        return results;
    }
This will buffer up to {@link #setMaxLength(int)} and then
ignore the rest of the text.

@param cbuf Character buffer
@param off  Offset into cbuf to first character in the run of text
@param len  Number of characters in the run of text.
tika-langdetect/tika-langdetect-opennlp/src/main/java/org/apache/tika/langdetect/opennlp/OpenNLPDetector.java