java.io.Closeable, java.io.Flushable, java.lang.AutoCloseablepublic class CsvWriter
extends java.lang.Object
implements java.io.Flushable, java.io.Closeable
Cell separator can be controlled.
End of line can be controlled.
Escaping end multi line cells are supported.
| Modifier and Type | Field | Description |
|---|---|---|
static char |
DEFAULT_SEPARATOR |
The default separator that should be used.
|
| Constructor | Description |
|---|---|
CsvWriter(java.io.File file) |
|
CsvWriter(java.io.File file,
boolean append) |
|
CsvWriter(java.io.File file,
java.lang.String charset) |
|
CsvWriter(java.io.File file,
java.lang.String charset,
boolean append) |
Creates a CSvWriter from a file.
|
CsvWriter(java.io.PrintStream s) |
Creates a CSvWriter from a PrintStream.
|
CsvWriter(java.io.PrintStream s,
java.lang.String charset) |
Creates a CSvWriter from a PrintStream.
|
CsvWriter(java.io.Writer writer) |
Create a CsvWriter from a writer.
|
CsvWriter(java.lang.String filename) |
|
CsvWriter(java.lang.String filename,
boolean append) |
|
CsvWriter(java.lang.String filename,
java.lang.String charset) |
|
CsvWriter(java.lang.String filename,
java.lang.String charset,
boolean append) |
Creates a CSvWriter from a file name.
|
| Modifier and Type | Method | Description |
|---|---|---|
void |
close() |
|
void |
flush() |
|
java.lang.String |
getLineSeparator() |
|
char |
getSeparator() |
|
void |
setLineSeparator(java.lang.String sep) |
Sets the line separator to use.
|
void |
setSeparator(char sep) |
Sets the cell separator.
|
void |
write(boolean value) |
Writes a boolean cell.
|
void |
write(boolean forceEscape,
java.lang.String... values) |
Writes an array of String cells and controls their escaping.
|
void |
write(byte value) |
Writes a byte cell.
|
void |
write(double value) |
Writes a double cell.
|
void |
write(float value) |
Writes a float cell.
|
void |
write(int value) |
Writes an int cell.
|
void |
write(long value) |
Writes a long cell.
|
void |
write(short value) |
Writes a short cell.
|
<E extends java.lang.Enum<E>> |
write(E value) |
Writes an enum cell.
|
void |
write(java.lang.CharSequence value) |
Writes a CharSequence cell, escaping it if necessary.
|
void |
write(java.lang.CharSequence value,
boolean forceEscape) |
Writes a CharSequence cell and controls its escaping.
|
void |
write(java.lang.String value) |
Writes a String cell, escaping it if necessary.
|
void |
write(java.lang.String... values) |
Writes an array of String cells, escaping them if necessary.
|
void |
write(java.lang.String value,
boolean forceEscape) |
Writes a String cell and controls its escaping.
|
void |
write(java.util.Collection<java.lang.String> values) |
Writes a collection of String cells, escaping them if necessary.
|
void |
write(java.util.Collection<java.lang.String> values,
boolean forceEscape) |
Writes a collection of String cells and controls their escaping.
|
void |
writeln() |
Writes the line separator (moves to next line).
|
void |
writeln(boolean forceEscape,
java.lang.String... values) |
Writes an array of String cells, controlling their escaping, then moves to next line.
|
void |
writeln(java.lang.String... values) |
Writes an array of String cells, escaping if necessary, then moves to next line.
|
void |
writeln(java.util.Collection<java.lang.String> values) |
Writes a collection of cells, escaping them if necessary, then moves to next line.
|
void |
writeln(java.util.Collection<java.lang.String> values,
boolean forceEscape) |
Writes a collection of String cells, controlling their escaping, then moves to next line.
|
public static final char DEFAULT_SEPARATOR
public CsvWriter(java.io.Writer writer)
writer - The writer.public CsvWriter(java.io.PrintStream s,
java.lang.String charset)
Buffering is used.
s - The PrintStream.charset - The charset name.public CsvWriter(java.io.PrintStream s)
Buffering is used.
s - The PrintStream.public CsvWriter(java.lang.String filename,
java.lang.String charset,
boolean append)
throws java.io.IOException
Buffering is used.
filename - The file name.charset - The charset name.append - If true, then bytes will be written to the end of the file rather than the beginning.java.io.IOException - When an IO error occurs.public CsvWriter(java.lang.String filename,
java.lang.String charset)
throws java.io.IOException
java.io.IOExceptionpublic CsvWriter(java.lang.String filename,
boolean append)
throws java.io.IOException
java.io.IOExceptionpublic CsvWriter(java.lang.String filename)
throws java.io.IOException
java.io.IOExceptionpublic CsvWriter(java.io.File file,
java.lang.String charset,
boolean append)
throws java.io.IOException
Buffering is used.
file - The file.charset - The charset name.append - If true, then bytes will be written to the end of the file rather than the beginning.java.io.IOException - When an IO error occurs.public CsvWriter(java.io.File file,
java.lang.String charset)
throws java.io.IOException
java.io.IOExceptionpublic CsvWriter(java.io.File file,
boolean append)
throws java.io.IOException
java.io.IOExceptionpublic CsvWriter(java.io.File file)
throws java.io.IOException
java.io.IOExceptionpublic char getSeparator()
public void setSeparator(char sep)
sep - The separator.public java.lang.String getLineSeparator()
public void setLineSeparator(java.lang.String sep)
sep - The line separator.public void writeln()
throws java.io.IOException
java.io.IOException - When an IO error occurs.public void write(java.lang.CharSequence value,
boolean forceEscape)
throws java.io.IOException
If necessary, a cell separator is first appended.
value - The cell.forceEscape - If true, cell is escaped. If false, cell is escaped if necessary.java.io.IOException - When an IO error occurs.public void write(java.lang.CharSequence value)
throws java.io.IOException
If necessary, a cell separator is first appended.
value - The cell.java.io.IOException - When an IO error occurs.public void write(java.lang.String value,
boolean forceEscape)
throws java.io.IOException
If necessary, a cell separator is first appended.
value - The cell.forceEscape - If true, cell is escaped. If false, cell is escaped if necessary.java.io.IOException - When an IO error occurs.public void write(java.lang.String value)
throws java.io.IOException
If necessary, a cell separator is first appended.
value - The cell.java.io.IOException - When an IO error occurs.public void write(java.util.Collection<java.lang.String> values,
boolean forceEscape)
throws java.io.IOException
If necessary, a cell separator is first appended. A cell separator is inserted between consecutive cells.
values - The cells.forceEscape - If true, all cells are escaped. If false, each cell is escaped if necessary.java.io.IOException - When an IO error occurs.public void write(java.util.Collection<java.lang.String> values)
throws java.io.IOException
If necessary, a cell separator is first appended.
A cell separator is inserted between consecutive cells.
Cells are escaped if necessary.
values - The cells.java.io.IOException - When an IO error occurs.public void writeln(java.util.Collection<java.lang.String> values,
boolean forceEscape)
throws java.io.IOException
If necessary, a cell separator is first appended. A cell separator is inserted between consecutive cells.
values - The cells.forceEscape - If true, all cells are escaped. If false, each cell is escaped if necessary.java.io.IOException - When an IO error occurs.public void writeln(java.util.Collection<java.lang.String> values)
throws java.io.IOException
If necessary, a cell separator is first appended.
A cell separator is inserted between consecutive cells.
Cells are escaped if necessary.
values - The cells.java.io.IOException - When an IO error occurs.public void write(boolean forceEscape,
java.lang.String... values)
throws java.io.IOException
If necessary, a cell separator is first appended. A cell separator is inserted between consecutive cells.
forceEscape - If true, all cells are escaped. If false, each cell is escaped if necessary.values - The cells.java.io.IOException - When an IO error occurs.public void write(java.lang.String... values)
throws java.io.IOException
If necessary, a cell separator is first appended. A cell separator is inserted between consecutive cells.
values - The cells.java.io.IOException - When an IO error occurs.public void writeln(boolean forceEscape,
java.lang.String... values)
throws java.io.IOException
If necessary, a cell separator is first appended. A cell separator is inserted between consecutive cells.
forceEscape - If true, all cells are escaped. If false, each cell is escaped if necessary.values - The cells.java.io.IOException - When an IO error occurs.public void writeln(java.lang.String... values)
throws java.io.IOException
If necessary, a cell separator is first appended. A cell separator is inserted between consecutive cells.
values - The cells.java.io.IOException - When an IO error occurs.public void write(boolean value)
throws java.io.IOException
If necessary, a cell separator is first appended.
value - The cell.java.io.IOException - When an IO error occurs.public void write(long value)
throws java.io.IOException
If necessary, a cell separator is first appended.
value - The cell.java.io.IOException - When an IO error occurs.public void write(int value)
throws java.io.IOException
If necessary, a cell separator is first appended.
value - The cell.java.io.IOException - When an IO error occurs.public void write(short value)
throws java.io.IOException
If necessary, a cell separator is first appended.
value - The cell.java.io.IOException - When an IO error occurs.public void write(byte value)
throws java.io.IOException
If necessary, a cell separator is first appended.
value - The cell.java.io.IOException - When an IO error occurs.public void write(double value)
throws java.io.IOException
If necessary, a cell separator is first appended.
value - The cell.java.io.IOException - When an IO error occurs.public void write(float value)
throws java.io.IOException
If necessary, a cell separator is first appended.
value - The cell.java.io.IOException - When an IO error occurs.public <E extends java.lang.Enum<E>> void write(E value)
throws java.io.IOException
If necessary, a cell separator is first appended.
E - The enum type.value - The cell.java.io.IOException - When an IO error occurs.public void flush()
throws java.io.IOException
flush in interface java.io.Flushablejava.io.IOExceptionpublic void close()
throws java.io.IOException
close in interface java.lang.AutoCloseableclose in interface java.io.Closeablejava.io.IOExceptionCopyright © 2019. All rights reserved.