Documentation of 'de.erichseifert.gral.io.data.CSVWriter' Java class
CSVWriter
de.erichseifert.gral.io.data

Class CSVWriter

  • All Implemented Interfaces:
    DataWriter


    public class CSVWriter
    extends AbstractDataWriter

    Class that writes all values of a DataSource to 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.

    CSVWriter instances should be obtained by the DataWriterFactory rather 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.String SEPARATOR_CHAR
      Key for specifying a Character value 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.
    • Field Detail

      • SEPARATOR_CHAR

        public static final java.lang.String SEPARATOR_CHAR
        Key for specifying a Character value 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

You see the box below because you did not login.