public class DelimitedWriter extends Object implements RecordWriter
If an escape character is configured, any field containing the delimiter will be escaped by placing the escape character immediately before the delimiter. For example, if the record "Field1,2", "Field3" is written using a comma delimiter and backslash escape character, the following text will be written to the output stream:
Field1\,2,Field3Note that no validation is performed when a record is written, so if an escape character is not configured and a field contains a delimiting character, the generated output may be invalid.
Constructor and Description |
---|
DelimitedWriter(Writer out)
Constructs a new DelimitedWriter.
|
DelimitedWriter(Writer out,
char delimiter)
Constructs a new DelimitedWriter.
|
DelimitedWriter(Writer out,
DelimitedParserConfiguration config)
Constructs a new DelimitedWriter.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the output stream.
|
void |
flush()
Flushes the output stream.
|
void |
write(Object value)
Writes a record object to this output stream.
|
void |
write(String[] record)
Writes a record to the output stream.
|
public DelimitedWriter(Writer out)
out
- the output stream to write topublic DelimitedWriter(Writer out, char delimiter)
out
- the output stream to write todelimiter
- the field delimiting characterpublic DelimitedWriter(Writer out, DelimitedParserConfiguration config)
out
- the output stream to write toconfig
- the delimited parser configurationpublic void write(Object value) throws IOException, RecordIOException
RecordWriter
write
in interface RecordWriter
value
- the record object to writeIOException
- if an I/O error occurs writing the record to the streamRecordIOException
public void write(String[] record) throws IOException
record
- the record to writeIOException
- if an I/O error occurspublic void flush() throws IOException
RecordWriter
flush
in interface RecordWriter
IOException
- if an I/O error occurs flushing the streampublic void close() throws IOException
RecordWriter
close
in interface RecordWriter
IOException
- if an I/O error occurs closing the stream