org.hsqldb.util
Class CSVWriter
- java.lang.Object
-
- org.hsqldb.util.CSVWriter
-
public class CSVWriter extends java.lang.Objecthelper class to write table data to a csv-file (comma separated values). the first line in file is a list of fieldnames, all following lines are data lines. a descptiontion of file format can be found on: http://www.wotsit.org/ usage: create a object using the constructor. call writeHeader for writing the filename header then add data with writeData. at the end close() closes the file.
-
-
Constructor Summary
Constructors Constructor and Description CSVWriter(java.io.File file, java.lang.String encoding)constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidclose()closes the csv file.voidwriteData(java.lang.String[] data)writes a data-record to the file.voidwriteHeader(java.lang.String[] header)writes the csv header (fieldnames).
-
-
-
Constructor Detail
-
CSVWriter
public CSVWriter(java.io.File file, java.lang.String encoding) throws java.io.IOExceptionconstructor. creates a csv file for writing data to it- Parameters:
file- the file to write data toencoding- encoding to use or null (=defualt)- Throws:
java.io.IOException
-
-
Method Detail
-
writeHeader
public void writeHeader(java.lang.String[] header) throws java.io.IOExceptionwrites the csv header (fieldnames). should be called after construction one time.- Parameters:
header- String[] with fieldnames- Throws:
java.io.IOException
-
writeData
public void writeData(java.lang.String[] data) throws java.io.IOExceptionwrites a data-record to the file. note that data[] must have same number of elements as the header had.- Parameters:
data- data to write to csv-file- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOExceptioncloses the csv file.- Throws:
java.io.IOException
-
-
DataMelt 3.0 © DataMelt by jWork.ORG