Class RDFWriter


  • public class RDFWriter
    extends java.lang.Object
    An RDFWriter is a process that will output triples or quads in an RDF syntax. RDFWriterBuilder provides the means to setup the writer.

    The process is

        DatasetGraph dsg = ...
        RDFWriter writer = RDFWriter.create().source(dsg).lang(Lang.TTL).build();
        OutputStream out =
        writer.output(out);
     
    or using abbreviated forms:
        RDFWriter.create().source(dsg).lang(Lang.TTL).output(out);
     
    See Also:
    WriterDatasetRIOT, WriterGraphRIOT
    • Method Detail

      • create

        public static RDFWriterBuilder create()
        Create an RDFWriterBuilder.

        Often used in a pattern such as:

            RDFWriter.create()
                .lang(Lang.TTL)
                .source(graph)
                .output(System.out);
         
      • asString

        public java.lang.String asString()
        Write and return as a string.

        The Lang or RDFFormat must have been set.

      • output

        public void output​(java.io.OutputStream output)
        Write the source to the OutputStream.

        The Lang or RDFFormat must have been set.

        Parameters:
        output -
      • output

        @Deprecated
        public void output​(java.io.Writer javaWriter)
        Deprecated.
        Using Java Writers risks corruption because of mismatch of character set. Only UTF-8 is safe.
        Write the source to the Java Writer.

        The Lang or RDFFormat must have been set.

        Parameters:
        javaWriter -
      • output

        public void output​(java.lang.String filename)
        Write the source to the file.

        If neither Lang nor RDFFormat are set, an attempt to guess an RDF Syntax is made from the file extension.

        Output to "-" goes to stdout.

        Parameters:
        filename -