Package org.jacoco.report.csv
Class DelimitedWriter
java.lang.Object
org.jacoco.report.csv.DelimitedWriter
Helper class for writing out CSV or tab delimited files.
Example Usage:
delimitedWriter.writeFields("header1", "header2", ...); for each line to be written { delimitedWriter.writeField(value1); delimitedWriter.writeField(value2); delimitedWriter.nextLine(); } delimitedWriter.close();
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDelimitedWriter
(Writer delegate) Creates a new Delimited writer using the default delimiterDelimitedWriter
(Writer delegate, char delimiter) Creates a new Delimited writer using the default delimiter -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Close the underlying writer object.private String
Escapes any occurrences of the quote character in value by replacing it with a double quote.void
nextLine()
Output a new line and advance the writer to the next line.void
write
(int value) Write a single integer value.void
write
(int... values) Write muliple integer valuesvoid
Write a single value.void
Write multiple fields at once.
-
Field Details
-
QUOTE
- See Also:
-
ESCAPED_QUOTE
- See Also:
-
DEFAULT_DELIMITER
private static final char DEFAULT_DELIMITER- See Also:
-
NEW_LINE
-
delimiter
private final char delimiter -
delegate
-
fieldPosition
private int fieldPosition
-
-
Constructor Details
-
DelimitedWriter
Creates a new Delimited writer using the default delimiter- Parameters:
delegate
- Writer to delegate all writes to
-
DelimitedWriter
Creates a new Delimited writer using the default delimiter- Parameters:
delegate
- Writer to delegate all writes todelimiter
- delimiter to use (usually a comma, tab or space)
-
-
Method Details
-
write
Write multiple fields at once. Values will be auto escaped and quoted as needed. Each value will be separated using the current delimiter- Parameters:
fields
- Values to write- Throws:
IOException
- Error writing to the underlying writer object
-
write
Write a single value. Values will be auto escaped and quoted as needed. If this is not the first field of the current line the value will be prepended with the current delimiter- Parameters:
field
- Value to write- Throws:
IOException
- Error writing to the underlying writer object
-
write
Write a single integer value.- Parameters:
value
- Value to write- Throws:
IOException
- Error writing to the underlying writer object
-
write
Write muliple integer values- Parameters:
values
- values to write- Throws:
IOException
- Error writing to the underlying writer object
-
nextLine
Output a new line and advance the writer to the next line. The line delimiter is the default for the platform.- Throws:
IOException
- Error writing to the underlying writer object
-
close
Close the underlying writer object. Once closed all write operations will fail- Throws:
IOException
- Error closing the underlying writer object
-
escape
Escapes any occurrences of the quote character in value by replacing it with a double quote. Also Quotes the value if a quote or delimiter value is found.- Parameters:
value
- String that needs escaping- Returns:
- New string with all values escaped
-