Package weka.core.converters
Class ConverterUtils.DataSink
java.lang.Object
weka.core.converters.ConverterUtils.DataSink
- All Implemented Interfaces:
Serializable
,RevisionHandler
- Enclosing class:
- ConverterUtils
Helper class for saving data to files. Via the ConverterUtils class it
determines which converter to use for saving the data. It is the logical
counterpart to
DataSource
.- Version:
- $Revision: 15656 $
- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
-
Constructor Summary
ConstructorDescriptionDataSink
(OutputStream stream) initializes the sink to save the data in the stream (always in ARFF format).initializes the sink to save the data to the given file.initializes the sink to save the data to the given Saver (expected to be fully configured). -
Method Summary
Modifier and TypeMethodDescriptionReturns the revision string.static void
for testing only - takes a data file as input and a data file for the output.static void
write
(OutputStream stream, Instances data) writes the data to the given stream (always in ARFF format).static void
writes the data to the given file.static void
writes the data via the given saver.void
writes the given data either via the saver or to the defined output stream (depending on the constructor).
-
Constructor Details
-
DataSink
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
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
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 Details
-
write
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
writes the data to the given file.- Parameters:
filename
- the file to write the data todata
- the data to store- Throws:
Exception
- if writing fails
-
write
writes the data via the given saver.- Parameters:
saver
- the saver to use for writing the datadata
- the data to store- Throws:
Exception
- if writing fails
-
write
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
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
-
getRevision
Returns the revision string.- Specified by:
getRevision
in interfaceRevisionHandler
- Returns:
- the revision
-