1

我试图重现这个使用 GraphStream 读取 GEXF 文件的示例,但它给了我这个错误消息:

Exception in thread "main" java.io.IOException: not a regular file 'sources\small-world-1.gexf'
at org.graphstream.stream.file.FileSourceFactory.sourceFor(FileSourceFactory.java:83)
at pack.age.Main.main(Main.java:15)

这是我的代码:

public class Main {

public static void main(String[] args) throws IOException {
    String filePath = "sources\\small-world-1.gexf";
    Graph g = new SingleGraph("g");
    FileSource fs = FileSourceFactory.sourceFor(filePath);

    fs.addSink(g);

    try {
        fs.begin(filePath);

        while (fs.nextEvents()) {
            // Optionally some code here ...
        }
    } catch( IOException e) {
        e.printStackTrace();
    }

    try {
        fs.end();
    } catch( IOException e) {
        e.printStackTrace();
    } finally {
        fs.removeSink(g);
    }
}


}

这是项目的层次结构:

在此处输入图像描述

我做错了什么 ?我该如何解决?

谢谢!

4

0 回答 0