import java.io.*;

/**
 * Demonstrate use of standard error and standard out
 * 
 * (Not using standard Javadoc to show what happens with the output.)
 * 
 * Run from the command line different ways:
 
    The standard way, where standard out and standard error are directed to the
    terminal:
 
      $ java StandardStreamsExample 
        This is to standard out 1
        This is to standard error 1
        This is to standard out 2
        This is to standard error 2
        
    Redirecting the output to a file named output:
    
      $ java StandardStreamsExample > out
        This is to standard error 1
        This is to standard error 2
      
        --> You still see the error messages because they are directed to the
        terminal, rather than to a file.
        
    Redirecting both standard out and standard error to their own files:
    
      $ java StandardStreamsExample 1> out 2> err
        $ cat out
        This is to standard out 1
        This is to standard out 2
        $ cat err 
        This is to standard error 1
        This is to standard error 2
        
    Redirecting both standard out and standard error to one file:
    
    $ java StandardStreamsExample 1> out 2>&1  
    $ cat out 
        This is to standard out 1
        This is to standard error 1
        This is to standard out 2
        This is to standard error 2

 * 
 * @author Sara Sprenkle
 */
public class StandardStreamsExample {

	/**
	 * 
	 * @param args
	 *            - not used in this program
	 */
	public static void main(String[] args) {

	    System.out.println("This is to standard out 1");
	    System.err.println("This is to standard error 1");
	    System.out.println("This is to standard out 2");
	    System.err.println("This is to standard error 2");
	}
}