View Javadoc

1   package org.kuali.maven.wagon;
2   
3   import java.io.ByteArrayOutputStream;
4   import java.io.PrintStream;
5   
6   /**
7    *
8    */
9   public class Foo {
10  
11      /**
12       * @param args
13       */
14      public static void main(final String[] args) {
15          try {
16              PrintStream oldOut = System.out;
17  
18              ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
19              PrintStream newOut = new PrintStream(bytesOut);
20              System.setOut(newOut);
21              System.out.print("foo");
22  
23              String s = bytesOut.toString() + " bar";
24              System.setOut(oldOut);
25              System.out.println(s);
26  
27          } catch (Exception e) {
28              e.printStackTrace();
29          }
30      }
31  
32  }