Class ExecOutputStream

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

    public class ExecOutputStream
    extends java.io.FilterOutputStream
    Class to pipe an OutputStream through a command using stdin/stdout. E.g.
        Writer w = new OutputStreamWriter(new ExecOutputStream(new FileOutputStream("file"), "command"));
     
    • Field Summary

      • Fields inherited from class java.io.FilterOutputStream

        out
    • Constructor Summary

      Constructors 
      Constructor Description
      ExecOutputStream​(java.io.OutputStream os, java.lang.Process p)
      Create a new ExecOutputStream on the given OutputStream using the process to filter the stream.
      ExecOutputStream​(java.io.OutputStream os, java.lang.String cmd)
      Create a new ExecOutputStream on the given OutputStream using the process to filter the stream.
      ExecOutputStream​(java.io.OutputStream os, java.lang.String[] cmd)
      Create a new ExecOutputStream on the given OutputStream using the process to filter the stream.
      ExecOutputStream​(java.io.OutputStream os, java.lang.String[] cmd, java.lang.String[] env)
      Create a new ExecOutputStream on the given OutputStream using the process to filter the stream.
      ExecOutputStream​(java.io.OutputStream os, java.lang.String cmd, java.lang.String[] env)
      Create a new ExecOutputStream on the given OutputStream using the process to filter the stream.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      void finalize()  
      void flush()  
      void write​(byte[] b)  
      void write​(byte[] b, int off, int len)  
      void write​(int b)  
      • Methods inherited from class java.io.OutputStream

        nullOutputStream
      • Methods inherited from class java.lang.Object

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

      • ExecOutputStream

        public ExecOutputStream​(java.io.OutputStream os,
                                java.lang.Process p)
                         throws java.io.IOException
        Create a new ExecOutputStream on the given OutputStream using the process to filter the stream.
        Parameters:
        os - Writes to this OutputStream
        p - Filters data through stdin/out on this Process
        Throws:
        java.io.IOException
      • ExecOutputStream

        public ExecOutputStream​(java.io.OutputStream os,
                                java.lang.String cmd)
                         throws java.io.IOException
        Create a new ExecOutputStream on the given OutputStream using the process to filter the stream.
        Parameters:
        os - Writes to this OutputStream
        cmd - Creates a Process from this string to filter data through stdin/out
        Throws:
        java.io.IOException
      • ExecOutputStream

        public ExecOutputStream​(java.io.OutputStream os,
                                java.lang.String[] cmd)
                         throws java.io.IOException
        Create a new ExecOutputStream on the given OutputStream using the process to filter the stream.
        Parameters:
        os - Writes to this OutputStream
        cmd - Creates a Process from this string array (command, arg, ...) to filter data through stdin/out
        Throws:
        java.io.IOException
      • ExecOutputStream

        public ExecOutputStream​(java.io.OutputStream os,
                                java.lang.String cmd,
                                java.lang.String[] env)
                         throws java.io.IOException
        Create a new ExecOutputStream on the given OutputStream using the process to filter the stream.
        Parameters:
        os - Writes to this OutputStream
        cmd - Creates a Process from this string to filter data through stdin/out
        env - Setup the environment for the command
        Throws:
        java.io.IOException
      • ExecOutputStream

        public ExecOutputStream​(java.io.OutputStream os,
                                java.lang.String[] cmd,
                                java.lang.String[] env)
                         throws java.io.IOException
        Create a new ExecOutputStream on the given OutputStream using the process to filter the stream.
        Parameters:
        os - Writes to this OutputStream
        cmd - Creates a Process from this string array (command, arg, ...) to filter data through stdin/out
        env - Setup the environment for the command
        Throws:
        java.io.IOException
    • Method Detail

      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class java.io.FilterOutputStream
        Throws:
        java.io.IOException
      • flush

        public void flush()
                   throws java.io.IOException
        Specified by:
        flush in interface java.io.Flushable
        Overrides:
        flush in class java.io.FilterOutputStream
        Throws:
        java.io.IOException
      • write

        public void write​(byte[] b)
                   throws java.io.IOException
        Overrides:
        write in class java.io.FilterOutputStream
        Throws:
        java.io.IOException
      • write

        public void write​(byte[] b,
                          int off,
                          int len)
                   throws java.io.IOException
        Overrides:
        write in class java.io.FilterOutputStream
        Throws:
        java.io.IOException
      • write

        public void write​(int b)
                   throws java.io.IOException
        Overrides:
        write in class java.io.FilterOutputStream
        Throws:
        java.io.IOException
      • finalize

        public void finalize()
        Overrides:
        finalize in class java.lang.Object