我想使用下面的代码将 Android 连接到 owl 文件,但是这一行
model = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM_TRANS_INF)
抛出异常。
public class OntoQuery {
private Model model;
public OntoQuery(String inputFileName) {
model = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM_TRANS_INF);
InputStream in = FileManager.get().open(inputFileName);
if(in == null) {
throw new IllegalArgumentException("File: " + inputFileName + " not found");
} else {
model.read(in, "RDF/XML");
}
}
public String executeQuery(String queryString) throws UnsupportedEncodingException {
Query query = QueryFactory.create(queryString);
QueryExecution qe = QueryExecutionFactory.create(query, this.model);
Throwable var5 = null;
String fieldValue;
try {
ResultSet results = qe.execSelect();
ByteArrayOutputStream go = new ByteArrayOutputStream();
ResultSetFormatter.out(go, results, query);
fieldValue = new String(go.toByteArray(), "UTF-8");
} catch (Throwable var15) {
var5 = var15;
throw var15;
} finally {
if(qe != null) {
if(var5 != null) {
try {
qe.close();
} catch (Throwable var14) {
//var5.addSuppressed(var14);
}
} else {
qe.close();
}
}
}
return fieldValue;
}
}