Package elki.result.textwriter
Class MultipleFilesOutput
- java.lang.Object
-
- elki.result.textwriter.MultipleFilesOutput
-
- All Implemented Interfaces:
StreamFactory,java.lang.AutoCloseable
public class MultipleFilesOutput extends java.lang.Object implements StreamFactory
Manage output to multiple files.- Since:
- 0.2
- Author:
- Erich Schubert
-
-
Field Summary
Fields Modifier and Type Field Description private java.nio.file.PathbasenameBase file name.private static java.lang.StringEXTENSIONFile name extension.private static java.lang.StringGZIP_EXTENSIONGZip extra file extensionprivate static LoggingLOGLogger for debugging.private booleanusegzipControl gzip compression of output.
-
Constructor Summary
Constructors Constructor Description MultipleFilesOutput(java.nio.file.Path base)ConstructorMultipleFilesOutput(java.nio.file.Path base, boolean gzip)Constructor
-
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!)private java.io.PrintStreamnewStream(java.lang.String name)Open a new stream of the given namejava.io.PrintStreamopenStream(java.lang.String filename)Retrieve the output stream for the given file name.
-
-
-
Field Detail
-
EXTENSION
private static final java.lang.String EXTENSION
File name extension.- See Also:
- Constant Field Values
-
GZIP_EXTENSION
private static final java.lang.String GZIP_EXTENSION
GZip extra file extension- See Also:
- Constant Field Values
-
basename
private java.nio.file.Path basename
Base file name.
-
usegzip
private boolean usegzip
Control gzip compression of output.
-
LOG
private static final Logging LOG
Logger for debugging.
-
-
Constructor Detail
-
MultipleFilesOutput
public MultipleFilesOutput(java.nio.file.Path base)
Constructor- Parameters:
base- Base file name (folder name)
-
MultipleFilesOutput
public MultipleFilesOutput(java.nio.file.Path base, boolean gzip)Constructor- Parameters:
base- Base file name (folder name)gzip- Use gzip compression.
-
-
Method Detail
-
newStream
private java.io.PrintStream newStream(java.lang.String name) throws java.io.IOExceptionOpen a new stream of the given name- Parameters:
name- file name (which will be appended to the base name)- Returns:
- stream object for the given name
- Throws:
java.io.IOException
-
openStream
public java.io.PrintStream openStream(java.lang.String filename) throws java.io.IOExceptionRetrieve the output stream for the given file name.- Specified by:
openStreamin interfaceStreamFactory- Parameters:
filename- Output label.- Returns:
- stream object for the given label
- Throws:
java.io.IOException- on IO error
-
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
-
-