Interface FileSink

All Superinterfaces:
AttributeSink, ElementSink, Sink
All Known Implementing Classes:
FileSinkBase, FileSinkBaseFiltered, FileSinkDGS, FileSinkDGSFiltered, FileSinkDOT, FileSinkDynamicGML, FileSinkGEXF, FileSinkGEXF2, FileSinkGML, FileSinkGraphML, FileSinkImages, FileSinkSVG, FileSinkTikZ, FileSinkUnstyledSVG

public interface FileSink
extends Sink
Output a graph or graph events to a file.

File outputs can work in two modes:

  • In the "writeAll()" mode, the file output is done "all at once" writing a "snapshot" of the graph at this particular instant in time. This mode cannot convey the dynamics of the graph.
  • In "begin()/end()" mode, the output is listener of an input (a graph or any other sort of graph events producer) and it write events as they come, conveying the dynamics of the graph correctly.

  • Method Details

    • writeAll

      void writeAll​(Graph graph, String fileName) throws IOException
      Write the current graph state in one big non-interruptible operation. This operation is a "snapshot" of the graph, it will never convey the dynamics of the graph. To ensure you store the graph "as it evolves in time" you must use the begin(OutputStream) or begin(String) as soon as the graph appears (or any source of graph event, any descendant of Source will do).
      Parameters:
      graph - The graph to send as events to the file.
      fileName - Name of the file to write.
      Throws:
      IOException - if an I/O error occurs while writing.
    • writeAll

      void writeAll​(Graph graph, OutputStream stream) throws IOException
      Write the current graph state in one big non-interruptible operation. This operation is a "snapshot" of the graph, it will never convey the dynamics of the graph. To ensure you store the graph "as it evolves in time" you must use the begin(Writer) or begin(OutputStream) or begin(String) as soon as the graph appears (or any source of graph event, any descendant of Source will do).
      Parameters:
      graph - The graph to send as events to the file.
      stream - The stream where the graph is sent.
      Throws:
      IOException - if an I/O error occurs while writing.
    • writeAll

      void writeAll​(Graph graph, Writer writer) throws IOException
      Write the current graph state in one big non-interruptible operation. This operation is a "snapshot" of the graph, it will never convey the dynamics of the graph. To ensure you store the graph "as it evolves in time" you must use the begin(Writer) or begin(OutputStream) or begin(String) as soon as the graph appears (or any source of graph event, any descendant of Source will do).
      Parameters:
      graph - The graph to send as events to the file.
      writer - The writer where the graph is sent.
      Throws:
      IOException - if an I/O error occurs while writing.
    • begin

      void begin​(String fileName) throws IOException
      Begin the output of the given stream of graph events. The graph events can come from any input (implementation of Source or you can directly use the methods inherited from Sink. Once the writing is started using begin(), you must close it using end() when done to ensure data is correctly stored in the file.
      Parameters:
      fileName - The name of the file where to output the graph events.
      Throws:
      IOException - If an I/O error occurs while writing.
    • begin

      void begin​(OutputStream stream) throws IOException
      Begin the output of the given stream of graph events. The graph events can come from any input (implementation of Source or you can directly use the methods inherited from Sink. Once the writing is started using begin(), you must close it using end() when done to ensure data is correctly stored in the file.
      Parameters:
      stream - The file stream where to output the graph events.
      Throws:
      IOException - If an I/O error occurs while writing.
    • begin

      void begin​(Writer writer) throws IOException
      Begin the output of the given stream of graph events. The graph events can come from any input (implementation of Source or you can directly use the methods inherited from Sink. Once the writing is started using begin(), you must close it using end() when done to ensure data is correctly stored in the file.
      Parameters:
      writer - The writer where to output the graph events.
      Throws:
      IOException - If an I/O error occurs while writing.
    • flush

      void flush() throws IOException
      Ensure all data sent to the output are correctly written.
      Throws:
      IOException - If an I/O error occurs during write.
    • end

      void end() throws IOException
      End the writing process started with begin(OutputStream) or begin(String).
      Throws:
      IOException