code: public void detectLang() throws IOException {
          LanguageDetector languageDetector = makeDetector();
          TextObjectFactory textObjectFactory = CommonTextObjectFactories.forDetectingOnLargeText();
  
          for (String filename: arglist) {
              try (BufferedReader is = new BufferedReader(new InputStreamReader(new FileInputStream(filename), "utf-8"))) {
                  TextObject textObject = textObjectFactory.create().append(is);
                  List<DetectedLanguage> probabilities = languageDetector.getProbabilities(textObject);
                  System.out.println(filename + ":" + probabilities);
              }
          }
      }
docs: Language detection test for each file (--detectlang option)
  
  <pre>
  usage: --detectlang -d [profile directory] -a [alpha] -s [seed] [test file(s)]
  </pre>