public static LanguageProfilerBuilder create(String name, InputStream is, String encoding)
            throws TikaException {

        LanguageProfilerBuilder newProfile =
                new LanguageProfilerBuilder(name, ABSOLUTE_MIN_NGRAM_LENGTH,
                        ABSOLUTE_MAX_NGRAM_LENGTH);
        BufferedInputStream bis = new BufferedInputStream(is);

        byte[] buffer = new byte[4096];
        StringBuilder text = new StringBuilder();
        int len;

        try {
            while ((len = bis.read(buffer)) != -1) {
                text.append(new String(buffer, 0, len, encoding));
            }
        } catch (IOException e) {
            throw new TikaException("Could not create profile, " + e.getMessage());
        }

        newProfile.analyze(text);
        return newProfile;
    }
Creates a new Language profile from (preferably quite large - 5-10k of
lines) text file

@param name     to be given for the profile
@param is       a stream to be read
@param encoding is the encoding of stream
@throws TikaException if could not create a language profile
tika-langdetect/tika-langdetect-tika/src/main/java/org/apache/tika/langdetect/tika/LanguageProfilerBuilder.java