de.erichseifert.gral.io.data
Class CSVWriter
- java.lang.Object
-
- de.erichseifert.gral.io.IOCapabilitiesStorage
-
- de.erichseifert.gral.io.data.AbstractDataWriter
-
- de.erichseifert.gral.io.data.CSVWriter
-
- All Implemented Interfaces:
- DataWriter
public class CSVWriter extends AbstractDataWriter
Class that writes all values of a
DataSourceto a character separated file. The file then stores the values separated by a certain delimiter character. The delimiter is chosen based on the file type but can also be set manually. By default the comma character will be used as a delimiter for separating columns. Lines end with a carriage return and a line feed character.CSVWriterinstances should be obtained by theDataWriterFactoryrather than being created manually:DataWriterFactory factory = DataWriterFactory.getInstance(); DataWriter writer = factory.get("text/csv"); writer.write(data, new FileOutputStream(filename));- See Also:
- RFC 4180
-
-
Field Summary
Fields Modifier and Type Field and Description static java.lang.StringSEPARATOR_CHARKey for specifying aCharactervalue that defines the delimiting character used to separate columns.
-
Constructor Summary
Constructors Constructor and Description CSVWriter(java.lang.String mimeType)Creates a new instance with the specified MIME-Type.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidwrite(DataSource data, java.io.OutputStream output)Stores the specified data source.-
Methods inherited from class de.erichseifert.gral.io.data.AbstractDataWriter
getMimeType, getSetting, setSetting
-
Methods inherited from class de.erichseifert.gral.io.IOCapabilitiesStorage
getCapabilities
-
-
-
-
Field Detail
-
SEPARATOR_CHAR
public static final java.lang.String SEPARATOR_CHAR
Key for specifying aCharactervalue that defines the delimiting character used to separate columns.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
CSVWriter
public CSVWriter(java.lang.String mimeType)
Creates a new instance with the specified MIME-Type. The delimiter is set depending on the MIME type parameter. By default a comma is used as a delimiter.- Parameters:
mimeType- MIME-Type of the output file.
-
-
Method Detail
-
write
public void write(DataSource data, java.io.OutputStream output) throws java.io.IOException
Stores the specified data source.- Parameters:
data- DataSource to be stored.output- OutputStream to be written to.- Throws:
java.io.IOException- if writing the data failed
-
-
DataMelt 3.0 © DataMelt by jWork.ORG