有没有办法从 .fdt/.fdx/.fdt 文件格式 java 中读取文本?

Is there any way to read text from .fdt/.fdx/.fdxt ftile from java?

我想统计.fdt/.fdx/.fdxt文件的字数

我将 .fdxt 转换为 .html 然后进一步解析它。它在某些情况下是成功的,但不是全部。

    String html="";

    Scanner sc = new Scanner(new File("/home/de-10/Desktop/1.html"));
    while(sc.hasNextLine()) {
        html+=sc.nextLine();
    }
    sc.close();

    System.out.println(html);

    Document doc = Jsoup.parse(html.toString());
    String data = doc.text();
    System.out.println(data);

    Scanner sc1 = new Scanner(new String(data));
    int wordCount=0;
    while(sc1.hasNext()) {
        sc1.next();
        wordCount++;
    }
    sc1.close();

    System.out.println("");
    System.out.println("**********");
    System.out.println("WordCount: "+wordCount);
    System.out.println("**********");
    System.out.println("");

我正在寻找一些最佳解决方案。

你说,“它在某些情况下是成功的,但不是全部”。所以我建议在计算之前从文本中删除标点符号。

int wordCount = Jsoup.parse(html).text().replaceAll("\p{Punct}", "").split("\s+").length;