Class ByteFilteringOutputStream

java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
org.apache.nifi.processors.hadoop.util.ByteFilteringOutputStream
All Implemented Interfaces:
Closeable, Flushable, AutoCloseable

public class ByteFilteringOutputStream extends FilterOutputStream
This class allows the user to define byte-array filters or single-byte filters that will modify the content that is written to the underlying stream. Each filter can be given a maximum number of replacements that it should perform.
  • Field Details

  • Constructor Details

  • Method Details

    • write

      public void write(byte[] buffer, int offset, int length) throws IOException
      Overrides:
      write in class FilterOutputStream
      Throws:
      IOException
    • write

      public void write(int data) throws IOException
      Overrides:
      write in class FilterOutputStream
      Throws:
      IOException
    • addFilter

      public void addFilter(byte[] toReplace, byte[] replaceWith)
      Causes this stream to write replaceWith in place of toReplace if write(byte[], int, int) is called where the value to write is equal to toReplace.

      Parameters:
      toReplace - the byte array to replace
      replaceWith - the byte array to be substituted
    • addFilter

      public void addFilter(byte[] toReplace, byte[] replaceWith, int maxReplacements)
      Causes this stream to write replaceWith in place of toReplace if write(byte[], int, int) is called where the value to write is equal to toReplace.

      Parameters:
      toReplace - the byte array to replace
      replaceWith - the byte array to be substituted
      maxReplacements - the maximum number of replacements that should be made
    • addFilter

      public void addFilter(byte toReplace, byte replaceWith)
      Causes this stream to write replaceWith in place of toReplace if write(int) is called where the value to write is equal to toReplace.

      Parameters:
      toReplace - the byte to replace
      replaceWith - the byte to be substituted
    • addFilter

      public void addFilter(byte toReplace, byte replaceWith, int maxReplacements)
      Causes this stream to write replaceWith in place of toReplace if write(int) is called where the value to write is equal to toReplace.

      Parameters:
      toReplace - the byte to replace
      replaceWith - the byte to be substituted
      maxReplacements - the maximum number of replacements that should be made