@Override
    public void addText(char[] cbuf, int off, int len) {
        if (hasEnoughText()) {
            return; // do nothing if we've already got enough text.
        }

        writer.write(cbuf, off, len);

        // FUTURE - use support to get padding char from NGramExtractors.standard().
        // We'd like to get the textPadding character from the NGramExtractor, but
        // that's not exposed. NGramExtractors.standard() returns extractor with ' '
        // as padding, so that's what we'll use here.
        writer.write(' ');
    }
Implementation of the LanguageDetector API that uses
https://github.com/optimaize/language-detector
tika-langdetect/tika-langdetect-optimaize/src/main/java/org/apache/tika/langdetect/optimaize/OptimaizeLangDetector.java