有没有办法从java读取.fdt/.fdx/.fdxt ftile中的文本?
我想计算.fdt/.fdx/.fdxt文件中的字数 我将.fdxt转换为.html,然后进一步解析它。它在某些情况下是成功的,但不是全部有没有办法从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
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