Package com.groiss.fileimport.csv
Class CSVWriter
java.lang.Object
com.groiss.fileimport.csv.CSVWriter
- All Implemented Interfaces:
Closeable
,AutoCloseable
a utility class which writes RFC4180 (CSV http://tools.ietf.org/html/rfc4180)
compliant records to a outputstream
many setter-methods for changing the behavior are available
there's also a way for writing fixed length records
-
Constructor Summary
ConstructorDescriptionCSVWriter
(CSVSettings settings) CSVWriter
(OutputStream out) CSVWriter
(OutputStream out, CSVSettings settings) CSVWriter
(OutputStream out, Charset charset) CSVWriter
(Writer input, CSVSettings settings) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
closes the underlying writervoid
the next time you usewrite(Object)
a new record will be startedvoid
flush()
the underlying writer will be flushedvoid
writes the given objectvoid
writes all recordsvoid
writeAll
(TableModel tm) writes the whole tmTableModel.getColumnName(int)
for headervoid
writeComment
(String comment) void
writeHeader
(List<String> header) write the header-recordvoid
writeRecord
(List<?> line) writes a whole record
-
Constructor Details
-
CSVWriter
- Parameters:
settings
- the settings to use
-
CSVWriter
public CSVWriter(Element config) throws InstantiationException, IllegalAccessException, ClassNotFoundException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException -
CSVWriter
- Parameters:
out
- the stream the data will be written to
-
CSVWriter
- Parameters:
out
- the stream the data will be written tocharset
- the charset to be used
-
CSVWriter
- Parameters:
out
- the stream the data will be written tosettings
- the settings to use
-
CSVWriter
- Parameters:
input
- the reader to read from
-
CSVWriter
- Parameters:
input
- the reader to read fromsettings
- the settings to use
-
-
Method Details
-
close
closes the underlying writer- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
endRecord
the next time you usewrite(Object)
a new record will be started- Throws:
IOException
-
flush
the underlying writer will be flushed- Throws:
IOException
-
getSettings
- Returns:
- the settings
-
write
writes the given object- Parameters:
obj
-- Throws:
IOException
-
writeAll
writes all records- Parameters:
lines
-- Throws:
IOException
-
writeAll
writes the whole tmTableModel.getColumnName(int)
for header- Parameters:
tm
-- Throws:
IOException
-
writeHeader
write the header-record- Parameters:
header
-- Throws:
IOException
-
writeRecord
writes a whole record- Parameters:
line
-- Throws:
IOException
-
writeComment
- Throws:
IOException
-