class FilterFileByLanguage {

  private final static String fastTextBinary = "/home/languagetool/fasttext/fasttext";
  private final static String fastTextModel = "/home/languagetool/fasttext/lid.176.bin";
  private final static String nGramData = "/home/languagetool/model_ml50_new.zip";
  private final static float skipThreshold = 0.95f; // only skip if confidence is higher than this

  public static void main(String[] args) throws IOException {<FILL_FUNCTION_BODY>}

}

    if (args.length != 2) {
      System.out.println("Usage: " + FilterFileByLanguage.class.getSimpleName() + " <langCode> <file>");
      System.exit(1);
    }
    String expectedLang = args[0];
    File input = new File(args[1]);
    File output = new File(input.getAbsoluteFile() + ".filtered");
    LanguageIdentifier ident = LanguageIdentifierService.INSTANCE.getDefaultLanguageIdentifier(0,
      new File(nGramData), new File(fastTextBinary), new File(fastTextModel));
    Scanner sc = new Scanner(input);
    int skipCount = 0;
    try (FileWriter fw = new FileWriter(output)) {
      while (sc.hasNextLine()) {
        String line = sc.nextLine();
        DetectedLanguage lang = ident.detectLanguage(line, Collections.emptyList(), Collections.emptyList());
        if (lang != null && !lang.getDetectedLanguage().getShortCode().equals(expectedLang) && lang.getDetectionConfidence() > skipThreshold) {
          System.out.printf("Skipping (%.2f, %s): %s\n", lang.getDetectionConfidence(), lang.getDetectedLanguage().getShortCode(), line);
          skipCount++;
        } else {
          fw.write(line);
          fw.write("\n");
        }
      }
    }
    System.out.println(skipCount + " lines skipped, confidence threshold was " + skipThreshold);
    System.out.println("Filtered result written to " + output);
  
<no_super_class>