Class WriterBySection
java.lang.Object
com.compomics.util.io.compression.SectionGzWriter.WriterBySection
- All Implemented Interfaces:
AutoCloseable
This writer writes the different sections of a file in temp files and bundles
them together upon completion.
- Author:
- Marc Vaudel
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe size of the char buffer to use when copying files.final booleanIf true, temp files are deleted upon completion.final booleanIf true, temp files are gzipped. -
Constructor Summary
ConstructorsConstructorDescriptionWriterBySection(File destinationFile, File tempFolder, boolean deleteTempFiles, boolean gzipTemp, boolean gzipDestination) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidAppends a new line to the given section.voidregisterSection(String sectionName) Registers a new section.voidsectionCompleted(String sectionName) Registers a section as completed and transfers its content to the main file.voidWrites content to the given section.voidWrites content to the given section.
-
Field Details
-
CHAR_BUFFER_SIZE
public static final int CHAR_BUFFER_SIZEThe size of the char buffer to use when copying files.- See Also:
-
deleteTempFiles
public final boolean deleteTempFilesIf true, temp files are deleted upon completion. -
gzipTemp
public final boolean gzipTempIf true, temp files are gzipped.
-
-
Constructor Details
-
WriterBySection
public WriterBySection(File destinationFile, File tempFolder, boolean deleteTempFiles, boolean gzipTemp, boolean gzipDestination) throws FileNotFoundException, IOException Constructor.- Parameters:
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.- Throws:
FileNotFoundException- Exception thrown if a file is not found.IOException- Exception thrown if an error occurred while reading or writing a file.
-
-
Method Details
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-
registerSection
Registers a new section. The section name should not contain special characters forbidden in file names.- Parameters:
sectionName- The name of the section.- Throws:
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.
-
sectionCompleted
Registers a section as completed and transfers its content to the main file.- Parameters:
sectionName- The name of the section.
-
newLine
Appends a new line to the given section.- Parameters:
sectionName- The name of the section.
-
write
Writes content to the given section.- Parameters:
sectionName- The name of the section.content- The content to write.
-
write
Writes content to the given section.- Parameters:
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 write
-