public class WriterBySection extends Object implements AutoCloseable
Modifier and Type | Field and Description |
---|---|
static int |
CHAR_BUFFER_SIZE
The size of the char buffer to use when copying files.
|
boolean |
deleteTempFiles
If true, temp files are deleted upon completion.
|
boolean |
gzipTemp
If true, temp files are gzipped.
|
Constructor and Description |
---|
WriterBySection(File destinationFile,
File tempFolder,
boolean deleteTempFiles,
boolean gzipTemp,
boolean gzipDestination)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
void |
newLine(String sectionName)
Appends a new line to the given section.
|
void |
registerSection(String sectionName)
Registers a new section.
|
void |
sectionCompleted(String sectionName)
Registers a section as completed and transfers its content to the main
file.
|
void |
write(String sectionName,
char[] buffer,
int offset,
int length)
Writes content to the given section.
|
void |
write(String sectionName,
String content)
Writes content to the given section.
|
public static final int CHAR_BUFFER_SIZE
public final boolean deleteTempFiles
public final boolean gzipTemp
public WriterBySection(File destinationFile, File tempFolder, boolean deleteTempFiles, boolean gzipTemp, boolean gzipDestination) throws FileNotFoundException, IOException
destinationFile
- The destination file.tempFolder
- The folder to write intermediate files to.deleteTempFiles
- If true, temp files are deleted upon completion.gzipTemp
- If true, temp files are gzipped.gzipDestination
- If true, the destination file is gzipped.FileNotFoundException
- Exception thrown if a file is not found.IOException
- Exception thrown if an error occurred while reading
or writing a file.public void close()
close
in interface AutoCloseable
public void registerSection(String sectionName) throws FileNotFoundException, IOException
sectionName
- The name of the section.FileNotFoundException
- Exception thrown if the temp folder does
not exist or is not writable.IOException
- Exception thrown if an error occurred while writing
the temp file.public void sectionCompleted(String sectionName)
sectionName
- The name of the section.public void newLine(String sectionName)
sectionName
- The name of the section.public void write(String sectionName, String content)
sectionName
- The name of the section.content
- The content to write.public void write(String sectionName, char[] buffer, int offset, int length)
sectionName
- The name of the section.buffer
- The buffer to write.offset
- The offset from which to start reading characters.length
- The maximal number of characters to writeCopyright © 2021. All rights reserved.