Class CsvSampleWriter

  • All Implemented Interfaces:
    java.io.Closeable , java.lang.AutoCloseable

    
    public class CsvSampleWriter
    extends AbstractSampleWriter
                        

    Class to be used to write samples to a csv destination (OutputStream, Writer or a File).

    This class handles csv header writing with the writeHeader method. This method has to be called by user for the header to be written.

    Since:

    3.0

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      void setWriter(Writer writer) Set the new writer on which samples will be written by this sample writer.
      void writeHeader() Write the csv header.
      long write(Sample sample) Write a sample to the underlying destination
      void setSeparator(char separator) Set the char to use for separation of data in a line.
      • Methods inherited from class org.apache.jmeter.report.core.AbstractSampleWriter

        close, setOutputFile, setOutputStream
      • Methods inherited from class java.io.Closeable

        close
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CsvSampleWriter

        CsvSampleWriter(SampleMetadata metadata)
        The new instance has to be supplied with a Writer to work properly.
        Parameters:
        metadata - the description for data that this writer will write (metadata must not be null).
      • CsvSampleWriter

        CsvSampleWriter(Writer output, SampleMetadata metadata)
        Parameters:
        output - the writer to write data to.
        metadata - the description for data that this writer will write.
      • CsvSampleWriter

        CsvSampleWriter(OutputStream output, SampleMetadata metadata)
        Parameters:
        output - the output stream to write data to.
        metadata - the description for data that this writer will write.
      • CsvSampleWriter

        CsvSampleWriter(File output, SampleMetadata metadata)
        Parameters:
        output - the output file to write data to.
        metadata - the description for data that this writer will write.
    • Method Detail

      • setWriter

         void setWriter(Writer writer)

        Set the new writer on which samples will be written by this sample writer. If any writer exists on the sample writer, it is flushed and closed before being replaced by the new one.

      • writeHeader

         void writeHeader()

        Write the csv header. If samples have already been written then a row with header information will be written in the middle of the file.

      • write

         long write(Sample sample)

        Write a sample to the underlying destination

        Parameters:
        sample - The sample to be written (Must not be null)
        Returns:

        The number of samples written at this time to the underlying destination

      • setSeparator

         void setSeparator(char separator)

        Set the char to use for separation of data in a line.

        Parameters:
        separator - to use