Package com.gengoai.io
Class MultiFileWriter
- java.lang.Object
-
- java.io.Writer
-
- com.gengoai.io.MultiFileWriter
-
- All Implemented Interfaces:
Closeable
,Flushable
,Serializable
,Appendable
,AutoCloseable
public class MultiFileWriter extends Writer implements Serializable, AutoCloseable
A writer that will write content to different files using a round robin strategy. It is important that the full content is written using one call to the write method to ensure the content goes to the same file.
- Author:
- David B. Bracewell
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description MultiFileWriter(Resource baseDirectory, String filePrefix, int numberOfFiles)
Instantiates a new Multi file writer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
void
flush()
void
write(char[] cbuf, int off, int len)
-
-
-
Constructor Detail
-
MultiFileWriter
public MultiFileWriter(Resource baseDirectory, String filePrefix, int numberOfFiles) throws IOException
Instantiates a new Multi file writer.- Parameters:
baseDirectory
- the base directory which will contain the filesfilePrefix
- the file prefix (each file have XXXXX appended on where XX is the file number)numberOfFiles
- the number of files- Throws:
IOException
- Something went wrong initializing the files
-
-
Method Detail
-
write
public void write(char[] cbuf, int off, int len) throws IOException
- Specified by:
write
in classWriter
- Throws:
IOException
-
flush
public void flush() throws IOException
- Specified by:
flush
in interfaceFlushable
- Specified by:
flush
in classWriter
- Throws:
IOException
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in classWriter
- Throws:
IOException
-
-