package org.trianacode.TrianaCloud.Utils;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

/**
 * @author Ian Harvey
 * @version 1.0.0 Apr 18, 2012
 */
public class StreamToOutput implements Runnable {

    private InputStream inputStream;
    private String description;
    private Thread thread;
    private BufferedReader inreader;

    public StreamToOutput(InputStream inputStream, String description) {
        this.inputStream = inputStream;
        this.description = description;
        inreader = new BufferedReader(new InputStreamReader(this.inputStream));

    }

    public void start() {
        thread = new Thread(this);
        thread.run();
    }

    @Override
    public void run() {
//        System.out.println("Reading stream : " + description);
        try {
            String str;
            while ((str = inreader.readLine()) != null) {
                System.out.println(" >> " + description + " : " + str);
            }
        } catch (IOException e) {
            System.out.println("Error with stream " + description + " closing");
        } finally {
            try {
                inreader.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
            System.out.println("Closed streamReader " + description);
        }
    }
}



@@ -156,16 +156,74 @@
 mReader;
+%0Aimport java.text.SimpleDateFormat;%0Aimport java.util.Date;
 %0A%0A/**%0A *
@@ -787,24 +787,203 @@
 run();%0A    %7D
+%0A    %0A    private String getTimeStamp() %7B%0A        SimpleDateFormat dateFormat = new SimpleDateFormat(%22yy-MM-dd_HH-mm-ss-SS_z%22);%0A        return dateFormat.format(new Date());%0A    %7D
 %0A%0A    @Overr
@@ -1207,16 +1207,39 @@
 rintln(%22
+%5B%22 + getTimeStamp() + %22
  %3E%3E %22 + 

Add date and time to output from StreamToOutput