Class ConverterUtils.DataSink

    • Constructor Detail

      • DataSink

        public DataSink​(String filename)
                 throws Exception
        initializes the sink to save the data to the given file.
        Parameters:
        filename - the file to save data to
        Throws:
        Exception - if set of saver fails
      • DataSink

        public DataSink​(Saver saver)
        initializes the sink to save the data to the given Saver (expected to be fully configured).
        Parameters:
        saver - the saver to use for saving the data
      • DataSink

        public DataSink​(OutputStream stream)
        initializes the sink to save the data in the stream (always in ARFF format).
        Parameters:
        stream - the output stream to use for storing the data in ARFF format
    • Method Detail

      • write

        public void write​(Instances data)
                   throws Exception
        writes the given data either via the saver or to the defined output stream (depending on the constructor). In case of the stream, the stream is only flushed, but not closed.
        Parameters:
        data - the data to save
        Throws:
        Exception - if saving fails
      • write

        public static void write​(String filename,
                                 Instances data)
                          throws Exception
        writes the data to the given file.
        Parameters:
        filename - the file to write the data to
        data - the data to store
        Throws:
        Exception - if writing fails
      • write

        public static void write​(Saver saver,
                                 Instances data)
                          throws Exception
        writes the data via the given saver.
        Parameters:
        saver - the saver to use for writing the data
        data - the data to store
        Throws:
        Exception - if writing fails
      • write

        public static void write​(OutputStream stream,
                                 Instances data)
                          throws Exception
        writes the data to the given stream (always in ARFF format).
        Parameters:
        stream - the stream to write the data to (ARFF format)
        data - the data to store
        Throws:
        Exception - if writing fails
      • main

        public static void main​(String[] args)
                         throws Exception
        for testing only - takes a data file as input and a data file for the output.
        Parameters:
        args - the commandline arguments
        Throws:
        Exception - if something goes wrong