Class AbstractSampleWriter

java.lang.Object
org.apache.jmeter.report.core.SampleWriter
org.apache.jmeter.report.core.AbstractSampleWriter
All Implemented Interfaces:
Closeable, AutoCloseable
Direct Known Subclasses:
CsvSampleWriter

public abstract class AbstractSampleWriter extends SampleWriter
Base class for implementing sample writer.

Handles buffering and output writer replacement.

When a writer is set on the sample writer any previous writer is flushed and closed before being replaced by the new one.

Since:
3.0
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected PrintWriter
    output writer to write samples to
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    This method is guaranteed to not throw any exception.
    void
    Set the destination file in which this sample writer will write samples
    void
    Instructs this sample writer to write samples on the specified output with UTG-8 encoding.
    void
    setWriter(Writer newWriter)
    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.

    Methods inherited from class org.apache.jmeter.report.core.SampleWriter

    write

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • writer

      protected PrintWriter writer
      output writer to write samples to
  • Constructor Details

    • AbstractSampleWriter

      public AbstractSampleWriter()
  • Method Details

    • setWriter

      public void setWriter(Writer newWriter)
      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.
      Parameters:
      newWriter - The destination writer where samples will be written by this sample writer
    • setOutputStream

      public void setOutputStream(OutputStream out)
      Instructs this sample writer to write samples on the specified output with UTG-8 encoding. The encoding can be overridden by the user through SaveService.getFileEncoding(String)
      Parameters:
      out - The output stream on which sample should be written
    • setOutputFile

      public void setOutputFile(File output)
      Set the destination file in which this sample writer will write samples
      Parameters:
      output - The output file that will receive samples written by this sample writer
    • close

      public void close()
      This method is guaranteed to not throw any exception. If writer is already closed then does nothing.
      Any buffered data is flushed by this method.