Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/89.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
有没有办法从java读取.fdt/.fdx/.fdxt ftile中的文本?_Java_Html_Parsing_Html Parsing_Fdt - Fatal编程技术网

有没有办法从java读取.fdt/.fdx/.fdxt ftile中的文本?

有没有办法从java读取.fdt/.fdx/.fdxt ftile中的文本?,java,html,parsing,html-parsing,fdt,Java,Html,Parsing,Html Parsing,Fdt,我想计算.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(); Syst

我想计算.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;
你说,“它在某些情况下是成功的,但不是全部”。因此,我建议在数数之前去掉课文中的标点符号

int wordCount = Jsoup.parse(html).text().replaceAll("\\p{Punct}", "").split("\\s+").length;
当我说“我将.fdxt转换为.html”时,我只是将.fdxt重命名为.html。当我说“我将.fdxt转换为.html”时,我只是将.fdxt重命名为.html