0

我是 Java 的新手,所以我为我在这一点上缺乏大量的主题而道歉。我正在尝试编写一个 html 解析器,它分析并返回来自以下 URL 的元素的数据:http ://en.wikipedia.org/wiki/Neurons 。

运行程序时,我不断收到此错误消息:

Exception in thread "main" java.io.FileNotFoundException: src/product.txt`: (No such file or directory)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(FileInputStream.java:120)
    at org.jsoup.helper.DataUtil.load(DataUtil.java:36)
    at org.jsoup.Jsoup.parse(Jsoup.java:88)
    at ParserPractice2.main(ParserPractice2.java:16)

我当前的代码如下所示:

import java.io.File;
import java.io.IOException;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.parser.*;
public class ParserPractice2 {

    public static void main(String[] args) throws IOException {

        File input = new File ("src/product.txt`:");

        Document doc = Jsoup.parse(input, "UTF-8", "http://en.wikipedia.org/wiki/Neurons");

        Element content = doc.getElementById("bodyContent");
    }}*

Any help/feedback would be greatly appreciated by this noobie =)Thanks!
4

1 回答 1

1

此文件不存在:

new File ("src/product.txt`:");

也许你的意思是"src/product.txt"

于 2013-01-16T17:54:50.313 回答