Class WriterPipedInputStream

java.lang.Object
java.io.InputStream
java.io.PipedInputStream
org.deltafi.common.io.WriterPipedInputStream
All Implemented Interfaces:
Closeable, AutoCloseable
Direct Known Subclasses:
FlowFileInputStream

public class WriterPipedInputStream extends PipedInputStream
An InputStream providing data written to a supplied Writer running in a separate thread.
  • Constructor Details

  • Method Details

    • create

      public static WriterPipedInputStream create(Writer writer, ExecutorService executorService) throws IOException
      Creates a WriterPipedInputStream with a default buffer size, starting a separate thread for writing.
      Parameters:
      writer - the Writer that will write bytes to be available to this WriterPipedInputStream
      executorService - the ExecutorService used to submit the writing thread
      Returns:
      the WriterPipedInputStream
      Throws:
      IOException - if an I/O error occurs
    • create

      public static WriterPipedInputStream create(Writer writer, ExecutorService executorService, int bufferSize) throws IOException
      Creates a WriterPipedInputStream, starting a separate thread for writing.
      Parameters:
      writer - the Writer that will write bytes to be available to this WriterPipedInputStream
      executorService - the ExecutorService used to submit the writing thread
      bufferSize - the buffer size
      Returns:
      the WriterPipedInputStream
      Throws:
      IOException - if an I/O error occurs
    • runPipeWriter

      protected void runPipeWriter()
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class PipedInputStream
      Throws:
      IOException