本文整理了Java中org.eclipse.rdf4j.rio.Rio.write
方法的一些代码示例,展示了Rio.write
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Rio.write
方法的具体详情如下:
包路径:org.eclipse.rdf4j.rio.Rio
类名称:Rio
方法名:write
[英]Writes the given statements to the given OutputStream in the given format.
If the collection is a Model, its namespaces will also be written.
[中]将给定语句以给定格式写入给定的OutputStream。
如果集合是一个模型,那么它的名称空间也将被写入。
代码示例来源:origin: streampipes/streampipes-ce
public static String asString(Graph graph) throws RDFHandlerException
{
OutputStream stream = new ByteArrayOutputStream();
Rio.write(graph, stream, RDFFormat.JSONLD);
return stream.toString();
}
代码示例来源:origin: org.streampipes/streampipes-commons
public static String asString(Graph graph) throws RDFHandlerException {
OutputStream stream = new ByteArrayOutputStream();
RDFWriter writer = Utils.getRioWriter(stream);
Rio.write(graph, writer);
return stream.toString();
}
代码示例来源:origin: HuygensING/timbuctoo
public static void main(String[] args) throws Exception {
InputStream resourceAsStream = new FileInputStream(args[0]);
Model model = Rio.parse(resourceAsStream, "", RDFFormat.NQUADS);
Rio.write(model, new FileOutputStream(args[1]), RDFFormat.TURTLE);
}
}
代码示例来源:origin: streampipes/streampipes-ce
public static String asString(Graph graph) throws RDFHandlerException {
OutputStream stream = new ByteArrayOutputStream();
RDFWriter writer = Utils.getRioWriter(stream);
Rio.write(graph, writer);
return stream.toString();
}
代码示例来源:origin: org.eclipse.rdf4j/rdf4j-client
/**
* Writes the given single statement to the given {@link Writer} in the given format.
* <p>
*
* @param statement
* A statement to be written.
* @param output
* The {@link Writer} to write the statement to.
* @param dataFormat
* The {@link RDFFormat} to use when writing the statement.
* @throws RDFHandlerException
* Thrown if there is an error writing the statement.
* @throws UnsupportedRDFormatException
* If no {@link RDFWriter} is available for the specified RDF format.
*/
public static void write(Statement statement, Writer output, RDFFormat dataFormat)
throws RDFHandlerException
{
write(statement, output, dataFormat, new WriterConfig());
}
代码示例来源:origin: HuygensING/timbuctoo
@Override
public void commit() throws RdfProcessingFailedException {
try {
inputStream.close();
FileWriter newFileWriter = new FileWriter(descriptionFile, false); //false for overwrite file (true=concat)
Rio.write(model, newFileWriter, RDFFormat.RDFXML);
newFileWriter.flush();
newFileWriter.close();
importStatus.setStatus("Description saved");
} catch (IOException e) {
throw new RdfProcessingFailedException(e);
}
}
代码示例来源:origin: org.eclipse.rdf4j/rdf4j-client
/**
* Writes the given statement to the given {@link OutputStream} in the given format.
* <p>
*
* @param st
* The statement to be written.
* @param output
* The {@link OutputStream} to write the statement to.
* @param dataFormat
* The {@link RDFFormat} to use when writing the statement.
* @throws RDFHandlerException
* Thrown if there is an error writing the statement.
* @throws UnsupportedRDFormatException
* If no {@link RDFWriter} is available for the specified RDF format.
*/
public static void write(Statement st, OutputStream output, RDFFormat dataFormat)
throws RDFHandlerException
{
write(st, output, dataFormat, new WriterConfig());
}
代码示例来源:origin: org.eclipse.rdf4j/rdf4j-rio-api
/**
* Writes the given statements to the given {@link OutputStream} in the given format.
* <p>
* If the collection is a {@link Model}, its namespaces will also be written.
*
* @param model
* A collection of statements, such as a {@link Model}, to be written.
* @param output
* The {@link OutputStream} to write the statements to.
* @param dataFormat
* The {@link RDFFormat} to use when writing the statements.
* @throws RDFHandlerException
* Thrown if there is an error writing the statements.
* @throws UnsupportedRDFormatException
* If no {@link RDFWriter} is available for the specified RDF format.
*/
public static void write(Iterable<Statement> model, OutputStream output, RDFFormat dataFormat)
throws RDFHandlerException
{
write(model, output, dataFormat, new WriterConfig());
}
代码示例来源:origin: org.eclipse.rdf4j/rdf4j-client
/**
* Writes the given statements to the given {@link OutputStream} in the given format.
* <p>
* If the collection is a {@link Model}, its namespaces will also be written.
*
* @param model
* A collection of statements, such as a {@link Model}, to be written.
* @param output
* The {@link OutputStream} to write the statements to.
* @param dataFormat
* The {@link RDFFormat} to use when writing the statements.
* @throws RDFHandlerException
* Thrown if there is an error writing the statements.
* @throws UnsupportedRDFormatException
* If no {@link RDFWriter} is available for the specified RDF format.
*/
public static void write(Iterable<Statement> model, OutputStream output, RDFFormat dataFormat)
throws RDFHandlerException
{
write(model, output, dataFormat, new WriterConfig());
}
代码示例来源:origin: org.eclipse.rdf4j/rdf4j-client
/**
* Writes the given statements to the given {@link Writer} in the given format.
* <p>
* If the collection is a {@link Model}, its namespaces will also be written.
*
* @param model
* A collection of statements, such as a {@link Model}, to be written.
* @param output
* The {@link Writer} to write the statements to.
* @param dataFormat
* The {@link RDFFormat} to use when writing the statements.
* @throws RDFHandlerException
* Thrown if there is an error writing the statements.
* @throws UnsupportedRDFormatException
* If no {@link RDFWriter} is available for the specified RDF format.
*/
public static void write(Iterable<Statement> model, Writer output, RDFFormat dataFormat)
throws RDFHandlerException
{
write(model, output, dataFormat, new WriterConfig());
}
代码示例来源:origin: eclipse/rdf4j
/**
* Writes the given statement to the given {@link OutputStream} in the given format.
* <p>
*
* @param st
* The statement to be written.
* @param output
* The {@link OutputStream} to write the statement to.
* @param dataFormat
* The {@link RDFFormat} to use when writing the statement.
* @throws RDFHandlerException
* Thrown if there is an error writing the statement.
* @throws UnsupportedRDFormatException
* If no {@link RDFWriter} is available for the specified RDF format.
*/
public static void write(Statement st, OutputStream output, RDFFormat dataFormat)
throws RDFHandlerException
{
write(st, output, dataFormat, new WriterConfig());
}
代码示例来源:origin: eclipse/rdf4j
/**
* Writes the given single statement to the given {@link Writer} in the given format.
* <p>
*
* @param statement
* A statement to be written.
* @param output
* The {@link Writer} to write the statement to.
* @param dataFormat
* The {@link RDFFormat} to use when writing the statement.
* @throws RDFHandlerException
* Thrown if there is an error writing the statement.
* @throws UnsupportedRDFormatException
* If no {@link RDFWriter} is available for the specified RDF format.
*/
public static void write(Statement statement, Writer output, RDFFormat dataFormat)
throws RDFHandlerException
{
write(statement, output, dataFormat, new WriterConfig());
}
代码示例来源:origin: org.eclipse.rdf4j/rdf4j-rio-api
/**
* Writes the given single statement to the given {@link Writer} in the given format.
* <p>
*
* @param statement
* A statement to be written.
* @param output
* The {@link Writer} to write the statement to.
* @param dataFormat
* The {@link RDFFormat} to use when writing the statement.
* @throws RDFHandlerException
* Thrown if there is an error writing the statement.
* @throws UnsupportedRDFormatException
* If no {@link RDFWriter} is available for the specified RDF format.
*/
public static void write(Statement statement, Writer output, RDFFormat dataFormat)
throws RDFHandlerException
{
write(statement, output, dataFormat, new WriterConfig());
}
代码示例来源:origin: org.eclipse.rdf4j/rdf4j-rio-api
/**
* Writes the given statement to the given {@link OutputStream} in the given format.
* <p>
*
* @param st
* The statement to be written.
* @param output
* The {@link OutputStream} to write the statement to.
* @param dataFormat
* The {@link RDFFormat} to use when writing the statement.
* @throws RDFHandlerException
* Thrown if there is an error writing the statement.
* @throws UnsupportedRDFormatException
* If no {@link RDFWriter} is available for the specified RDF format.
*/
public static void write(Statement st, OutputStream output, RDFFormat dataFormat)
throws RDFHandlerException
{
write(st, output, dataFormat, new WriterConfig());
}
代码示例来源:origin: HuygensING/timbuctoo
private void createDescriptionNode(Description description, RDFFormat parseFormat, Interpreter interpreter) {
try {
Model model = Rio.parse(IOUtils.toInputStream(description.getRawContent()), "", parseFormat);
ByteArrayOutputStream out = new ByteArrayOutputStream();
Rio.write(model, out, RDFFormat.JSONLD);
ObjectMapper mapper = new ObjectMapper();
content = mapper.readTree(out.toString());
} catch (Exception e) { // catch all e.g. org.xml.sax.SAXParseException
rawContent = description.getRawContent();
error = new ErrorView(e, interpreter);
}
}
}
代码示例来源:origin: org.molgenis/molgenis-core-ui
@Override
protected void writeInternal(Model model, HttpOutputMessage httpOutputMessage) {
runAsSystem(
() -> {
try {
Rio.write(model, httpOutputMessage.getBody(), TURTLE);
httpOutputMessage.getBody().close();
} catch (IOException e) {
throw new UncheckedIOException(e);
}
});
}
}
代码示例来源:origin: com.powsybl/powsybl-triple-store-impl-rdf4j
private static void write(Model m, OutputStream out) {
try (PrintStream pout = new PrintStream(out)) {
RDFWriter w = new PowsyblWriter(pout);
w.getWriterConfig().set(BasicWriterSettings.PRETTY_PRINT, true);
Rio.write(m, w);
}
}
代码示例来源:origin: org.eclipse.rdf4j/rdf4j-client
private void removeModel(Model m)
throws RepositoryException
{
RDFFormat format = RDFFormat.BINARY;
try {
ByteArrayOutputStream out = new ByteArrayOutputStream();
Rio.write(m, out, format);
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
client.removeData(in, null, format);
}
catch (RDFHandlerException e) {
throw new RepositoryException("error while writing statement", e);
}
catch (RDFParseException e) {
throw new RepositoryException(e);
}
catch (IOException e) {
throw new RepositoryException(e);
}
}
代码示例来源:origin: eclipse/rdf4j
private void removeModel(Model m)
throws RepositoryException
{
RDFFormat format = RDFFormat.BINARY;
try {
ByteArrayOutputStream out = new ByteArrayOutputStream();
Rio.write(m, out, format);
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
client.removeData(in, null, format);
}
catch (RDFHandlerException e) {
throw new RepositoryException("error while writing statement", e);
}
catch (RDFParseException e) {
throw new RepositoryException(e);
}
catch (IOException e) {
throw new RepositoryException(e);
}
}
代码示例来源:origin: org.eclipse.rdf4j/rdf4j-repository-http
private void removeModel(Model m)
throws RepositoryException
{
RDFFormat format = RDFFormat.BINARY;
try {
ByteArrayOutputStream out = new ByteArrayOutputStream();
Rio.write(m, out, format);
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
client.removeData(in, null, format);
}
catch (RDFHandlerException e) {
throw new RepositoryException("error while writing statement", e);
}
catch (RDFParseException e) {
throw new RepositoryException(e);
}
catch (IOException e) {
throw new RepositoryException(e);
}
}
内容来源于网络,如有侵权,请联系作者删除!