Package elki.result.textwriter
Class SingleStreamOutput
- java.lang.Object
-
- elki.result.textwriter.SingleStreamOutput
-
- All Implemented Interfaces:
StreamFactory,java.lang.AutoCloseable
public class SingleStreamOutput extends java.lang.Object implements StreamFactory
Class to output all result data to a single stream (e.g., Stdout, single file)- Since:
- 0.2
- Author:
- Erich Schubert
-
-
Field Summary
Fields Modifier and Type Field Description private java.io.PrintStreamstreamOutput stream
-
Constructor Summary
Constructors Constructor Description SingleStreamOutput()Constructor using stdout.SingleStreamOutput(java.io.OutputStream out)Constructor with given FileOutputStream.SingleStreamOutput(java.io.OutputStream out, boolean gzip)Constructor with given FileOutputStream.SingleStreamOutput(java.io.PrintStream os)Constructor with a print stream.SingleStreamOutput(java.nio.file.Path out)Constructor with given file name.SingleStreamOutput(java.nio.file.Path out, boolean gzip)Constructor with given file name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Close stream factory.voidcloseStream(java.io.PrintStream stream)Close the given output stream (Note: when writing to a single stream output, it will actually not be closed!)java.io.PrintStreamopenStream(java.lang.String filename)Return the objects shared print stream.
-
-
-
Constructor Detail
-
SingleStreamOutput
public SingleStreamOutput() throws java.io.IOExceptionConstructor using stdout.- Throws:
java.io.IOException- on IO error
-
SingleStreamOutput
public SingleStreamOutput(java.nio.file.Path out) throws java.io.IOExceptionConstructor with given file name.- Parameters:
out- filename- Throws:
java.io.IOException- on IO error
-
SingleStreamOutput
public SingleStreamOutput(java.nio.file.Path out, boolean gzip) throws java.io.IOExceptionConstructor with given file name.- Parameters:
out- filenamegzip- Use gzip compression- Throws:
java.io.IOException- on IO error
-
SingleStreamOutput
public SingleStreamOutput(java.io.OutputStream out) throws java.io.IOExceptionConstructor with given FileOutputStream.- Parameters:
out- File output stream- Throws:
java.io.IOException- on IO error
-
SingleStreamOutput
public SingleStreamOutput(java.io.OutputStream out, boolean gzip) throws java.io.IOExceptionConstructor with given FileOutputStream.- Parameters:
out- File output streamgzip- Use gzip compression- Throws:
java.io.IOException- on IO error
-
SingleStreamOutput
public SingleStreamOutput(java.io.PrintStream os)
Constructor with a print stream.- Parameters:
os- Output stream
-
-
Method Detail
-
openStream
public java.io.PrintStream openStream(java.lang.String filename)
Return the objects shared print stream.- Specified by:
openStreamin interfaceStreamFactory- Parameters:
filename- ignored filename for SingleStreamOutput, as the name suggests- Returns:
- stream object for the given label
-
closeStream
public void closeStream(java.io.PrintStream stream)
Description copied from interface:StreamFactoryClose the given output stream (Note: when writing to a single stream output, it will actually not be closed!)- Specified by:
closeStreamin interfaceStreamFactory- Parameters:
stream- Stream to close
-
close
public void close() throws java.io.IOExceptionDescription copied from interface:StreamFactoryClose stream factory.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfaceStreamFactory- Throws:
java.io.IOException
-
-