耶拿fileManager找不到文件? [英] Jena fileManager cannot find file?
问题描述
我使用Jena FileManager从本地rdf文件加载模型. Java代码可以在Eclipse中正确运行.但是,当我从matlab调用此java类时.
I use Jena FileManager to load a model from a local rdf file. The java code run correctly in Eclipse. But when I call this java class from matlab.
部分源代码如下:
public static Set<String> getSubjectsRelatedToProperty(String filePath) throws IllegalArgumentException, URISyntaxException {
// read the resourceMap
FileManager fm = FileManager.get();
model = fm.loadModel(filePath);
return result_set;
}
我收到的错误附在下面.
The error I received is attached below.
--------------
Error Details:
--------------
Error using org.mycom/view (line 961)
Java exception occurred:
com.hp.hpl.jena.shared.NotFoundException: Not found: /Users/runs/1/abc.rdf
at com.hp.hpl.jena.util.FileManager.readModelWorker(FileManager.java:378)
at com.hp.hpl.jena.util.FileManager.loadModelWorker(FileManager.java:297)
at com.hp.hpl.jena.util.FileManager.loadModel(FileManager.java:248)
at org.mycom.QueryResourceMap.getSubjectsRelatedToProperty(QueryResourceMap.java:32)
推荐答案
eclipse项目的根目录与matlab项目的位置不同.那是我唯一想到的问题.您提供的文件路径/Users/runs/1/abc.rdf
包含一个斜杠,这表示文件搜索从应用程序的根目录开始.我可能只给出一个绝对文件路径,例如C:/example/example/abc.rdf
.这样,无论您将文件路径指定给哪个程序,都可以找到该文件.
The root directory for your eclipse project is in a different location than your matlab project. That's the only problem i can think of. The file path you give, /Users/runs/1/abc.rdf
, contains a leading slash, which means the file search starts from the root directory of the application. I would probably just give an absolute file path, like C:/example/example/abc.rdf
.This way you can find the file no matter what program you give the file path to.
或者,只需在Matlab目录中手动创建文件路径.因此,转到您的matlab项目根目录,并创建一个Users
文件夹,然后创建一个runs
文件夹,等等...
Or, just manually create your file path within the Matlab directory. So go to your matlab project root directory and create a Users
folder, then a runs
folder, etc...
这篇关于耶拿fileManager找不到文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!