private void update(int pos) {
                this.pos = pos;
                if (pos >= size) { // Reached the end
                    return;
                }
                final int origo = pos * (length + 2);
                System.arraycopy(entries, origo, ngram, 0, length);
                count = entries[origo + length] * 65536 + entries[origo + length + 1];
            }
Ensure that the entries array is in sync with the ngrams.
tika-langdetect/tika-langdetect-tika/src/main/java/org/apache/tika/langdetect/tika/LanguageProfile.java