Class StandardStreamsHandler

  • All Implemented Interfaces:
    java.lang.AutoCloseable

    class StandardStreamsHandler
    extends java.lang.Object
    implements java.lang.AutoCloseable
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.io.PrintStream stderr  
      private java.io.PrintStream stdout  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      private static boolean isSameFile​(java.nio.file.Path path1, java.nio.file.Path path2)  
      void redirectStandardStreams​(java.nio.file.Path stdoutPath, java.nio.file.Path stderrPath)
      Redirect standard output (stdout) and standard error (stderr) to the specified file paths.
      • Methods inherited from class java.lang.Object

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

      • stdout

        private java.io.PrintStream stdout
      • stderr

        private java.io.PrintStream stderr
    • Constructor Detail

      • StandardStreamsHandler

        public StandardStreamsHandler()
    • Method Detail

      • redirectStandardStreams

        public void redirectStandardStreams​(java.nio.file.Path stdoutPath,
                                            java.nio.file.Path stderrPath)
        Redirect standard output (stdout) and standard error (stderr) to the specified file paths.

        If the paths are the same, both streams are redirected to the same file.

        The default charset is used for writing to the files.

        Parameters:
        stdoutPath - the file path for standard output, or null to indicate no redirection
        stderrPath - the file path for standard error, or null to indicate no redirection
      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable
      • isSameFile

        private static boolean isSameFile​(java.nio.file.Path path1,
                                          java.nio.file.Path path2)