Package edu.ie3.datamodel.io.csv
Class BufferedCsvWriter
java.lang.Object
java.io.Writer
java.io.BufferedWriter
edu.ie3.datamodel.io.csv.BufferedCsvWriter
- All Implemented Interfaces:
Closeable
,Flushable
,Appendable
,AutoCloseable
This class extends the
BufferedWriter
and adds information about the file shape of the
csv file-
Field Summary
-
Constructor Summary
ConstructorDescriptionBufferedCsvWriter
(String baseFolder, CsvFileDefinition fileDefinition, boolean append) Build a new CsvBufferedWriter.BufferedCsvWriter
(String filePath, String[] headLineElements, String csvSep, boolean append) Build a new CsvBufferedWriter. -
Method Summary
Modifier and TypeMethodDescriptionappend
(char c) append
(CharSequence csq) append
(CharSequence csq, int start, int end) boolean
int
hashCode()
toString()
void
Actually persisting the provided entity field datafinal void
Writes the file header.Methods inherited from class java.io.Writer
nullWriter, write, write
-
Constructor Details
-
BufferedCsvWriter
public BufferedCsvWriter(String filePath, String[] headLineElements, String csvSep, boolean append) throws IOException Build a new CsvBufferedWriter. The order of headline elements given in this constructor defines the order of columns in file- Parameters:
filePath
- String representation of the full path to the target fileheadLineElements
- Elements of the csv headlinecsvSep
- csv separator charappend
- true to append to an existing file, false to overwrite an existing file (if any), if no file exists, a new one will be created in both cases- Throws:
IOException
- If the FileOutputStream cannot be established.
-
BufferedCsvWriter
public BufferedCsvWriter(String baseFolder, CsvFileDefinition fileDefinition, boolean append) throws IOException Build a new CsvBufferedWriter. This is a "convenience" Constructor. The absolute file path is assembled by concatenation ofbaseFolder
andfileDefinition
's file path information. The order of headline elements infileDefinition
defines the order of columns in file- Parameters:
baseFolder
- Base folder, from where the file hierarchy should startfileDefinition
- The foreseen shape of the fileappend
- true to append to an existing file, false to overwrite an existing file (if any), if no file exists, a new one will be created in both cases- Throws:
IOException
- If the FileOutputStream cannot be established.
-
-
Method Details
-
write
Actually persisting the provided entity field data- Parameters:
entityFieldData
- a mapping of an entity instance fields to their values- Throws:
IOException
- If writing has failedSinkException
- If the data does not meet the pre-defined head line
-
writeFileHeader
Writes the file header.- Throws:
IOException
- If something is messed up
-
append
- Specified by:
append
in interfaceAppendable
- Overrides:
append
in classWriter
-
append
- Specified by:
append
in interfaceAppendable
- Overrides:
append
in classWriter
-
append
- Specified by:
append
in interfaceAppendable
- Overrides:
append
in classWriter
-
equals
-
hashCode
public int hashCode() -
toString
-