public static void main(String[] args) throws IOException { Model model=ModelFactory.createDefaultModel(); model.read(new FileInputStream("simpsons.ttl"),null,"TTL"); }
/** * {@inheritDoc} */ @Override public Model read(InputStream in, String base) { return super.object.read(in, base); }
/** * {@inheritDoc} */ @Override public Model read(InputStream in, String base, String lang) { return super.object.read(in, base, lang); }
/** * {@inheritDoc} */ @Override public Model read(String url, String lang) { return super.object.read(url, lang); }
/** * {@inheritDoc} */ @Override public Model read(String url, String base, String lang) { return super.object.read(url, base, lang); }
import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.ModelFactory; public class JSONObjectTest { public static void main(String[] args) { Model model = ModelFactory.createDefaultModel(); model.read( JSONObjectTest.class.getResourceAsStream( "/jsonoutput.ttl"), null, "N3" ); model.write( System.out, "RDF/JSON" ); } }
public static void main(String[] args) { String fileNameOrUri = "src/a/rdfexample.ntriple"; Model model = ModelFactory.createDefaultModel(); InputStream is = FileManager.get().open(fileNameOrUri); if (is != null) { model.read(is, null, "N-TRIPLE"); model.write(System.out, "TURTLE"); } else { System.err.println("cannot read " + fileNameOrUri);; } }
final Model rdfModel = ModelFactory.createDefaultModel(); final HttpClient httpclient = new DefaultHttpClient(); final HttpParams params = httpclient.getParams(); params.setParameter(HttpConnectionParams.CONNECTION_TIMEOUT, 1000); params.setParameter(HttpConnectionParams.SO_TIMEOUT, 5000); HttpOp.setDefaultHttpClient(httpclient); rdfModel.read(resource);
Model model = VirtModel.openDatabaseModel("load:test", "jdbc:virtuoso://localhost:1111", "dba", "dba"); InputStream in = FileManager.get().open( nfile ); if (in == null) { throw new IllegalArgumentException( "File: " + nfile + " not found"); } model.read(new InputStreamReader(in), null, "N-TRIPLE"); model.close();
try { String nfile = "1.nt"; Model model = VirtModel.openDatabaseModel("load:test", "jdbc:virtuoso://localhost:1111", "dba", "dba"); InputStream in = FileManager.get().open( nfile ); if (in == null) { throw new IllegalArgumentException( "File: " + nfile + " not found"); } model.read(new InputStreamReader(in), null, "N-TRIPLE"); model.close(); } catch (Exception e) { System.out.println("Ex="+e); }
private synchronized void prepareModel() { m = ModelFactory.createDefaultModel(); m.read(new StringReader(baseModelString), ""); // m.read(GeneralJSONRDF.class.getResourceAsStream("rdf/base_usmf.rdf"), // ""); }
@Override public void readASCII(final Scanner in) throws IOException { final StringBuffer b = new StringBuffer(); while (in.hasNext()) { b.append(in.next()); } final InputStream stream = new ByteArrayInputStream(b.toString().getBytes("UTF-8")); m = ModelFactory.createDefaultModel(); m.read(stream, "", "NTRIPLES"); m.close(); }
private void importModelFromSingleFile(File file, String lang) { Model m = ModelFactory.createDefaultModel(); try { InputStream s = new FileInputStream(file); m.read(s, null); this.addModel(m, file.getName()); logger.info("The model " + file.getPath() + " successfully imported to repository"); } catch (Throwable t) { logger.error("Error reading the model file!", t); return; } }
public static Model cloneModel(Model model) { Model result = ModelFactory.createDefaultModel(); ByteArrayOutputStream out = new ByteArrayOutputStream(); model.write(out); ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); result.read(in, null); return result; }
private Model openModel(String OPMGraph) { Model m = ModelFactory.createDefaultModel(); // read the RDF/XML string m.read(fromString(OPMGraph),null); return m; }
private Model openModel(String OPMFileName) { m = ModelFactory.createDefaultModel(); // use the FileManager to find the input file InputStream in = FileManager.get().open( OPMFileName ); if (in == null) { throw new IllegalArgumentException("File: " + OPMFileName + " not found"); } // read the RDF/XML file m.read(in, null); return m; }
public void setContents(String contentsAsString) { if (contentsAsString.startsWith("<rdf:RDF")) { Model model = ModelFactory.createDefaultModel(); model.read(new StringReader(contentsAsString), null); Set<Resource> subjects = model.listSubjects().toSet(); Set<RDFNode> objects = model.listObjects().toSet(); subjects.removeAll(objects); node = subjects.iterator().next(); } else { node = RdfUtils.createTypedLiteral(contentsAsString); } }
private Model execModel(Model model) { HttpQuery httpQuery = makeHttpQuery() ; httpQuery.setAccept(HttpParams.contentTypeRDFXML) ; InputStream in = httpQuery.exec() ; model.read(in, null) ; return model ; }
public Model createRDFModel() throws IOException, DataServiceFault { InputStream in = DBUtils.getInputStreamFromPath(this.getRDFDataSourcePath()); Model model = ModelFactory.createMemModelMaker().createDefaultModel(); model.read(in,null); return model; }
@Test public void readURL() throws Exception { final Model model = ModelFactory.createDefaultModel(); final String url = getClass().getResource("../jena/relative.jsonld").toExternalForm(); final String baseUri = "http://example.com/"; model.read(url, baseUri, "JSON-LD"); model.write(System.out, "TURTLE", ""); checkRelative(model); } }