title: Redirecting program output as input - pipe not working
body: <p>I am taking the output of one program (C++) as input for another (Java) using <code>BufferedReader</code>. When I run the Java program in my IDE and enter input in the console the program works as expected, however, when I try to pipe the input from the C++ program it no longer works with no errors given - no output is shown on the terminal window and no data is entered into the database. It is also worth noting that if I try running the <code>jar</code> in a terminal window and entering input the program does not work there either.</p>
  
  <p>Reader Code: </p>
  
  <pre><code>BufferedReader input;
        try {
          input = new BufferedReader(new InputStreamReader(System.in));
          String outputLine;
          String visionObjectName;
          String visionObjectTimestamp;
          String word = null;
          String timestamp = null;
          String whiteSpace = null;
          // Regex is used to check that the output is an object "name blankSpace timestamp" to avoid random output such as errors being entered.
          while ((outputLine = input.readLine()) != null) {
            System.out.println(outputLine);
            String regEx = "(^[a-zA-Z]*)(\\s+)((?:2|1)\\d{3}(?:-|\\/)(?:(?:0[1-9])|(?:1[0-2]))(?:-|\\/)(?:(?:0[1-9])|(?:[1-2][0-9])|(?:3[0-1]))(?:T|\\s)(?:(?:[0-1][0-9])|(?:2[0-3])):(?:[0-5][0-9]):(?:[0-5][0-9]))";
            Pattern p = Pattern.compile(regEx, Pattern.CASE_INSENSITIVE | Pattern.DOTALL);
            Matcher m = p.matcher(outputLine);
            if (m.find()) {
              word = m.group(1);
              whiteSpace = m.group(2);
              timestamp = m.group(3);
            }
            visionObjectName = word + "" + whiteSpace;
            visionObjectTimestamp = timestamp;
            databasePopulation(visionObjectName, visionObjectTimestamp);
          }
  </code></pre>
  
  <p>I am using the Linux terminals pipe function to pass the information across.</p>
  
  <p>Command:</p>
  
  <pre><code>./ORBMarkerDetection | java -jar ../layers/out/artifacts/layers_jar/layers.jar
  </code></pre>
  
  <p>EDIT:
  For sake of thoroughness I've included the output code from the C++ program, would the method I'm using to print the timestamp be causing problems?</p>
  
  <pre><code>int timeFound() {
    time_t rawtime;
    struct tm * timeinfo;
    char buffer [80];
    time(&amp;rawtime);
    timeinfo = localtime (&amp;rawtime);
    strftime(buffer,80,"%Y-%m-%d %H:%M:%S",timeinfo);
    puts(buffer);
    return 0;
  }
  
  void printFunction(String objectName) {
    if(nameArray[0] != objectName) {
      nameArray[0] = objectName;
      cout &lt;&lt; nameArray[0] &lt;&lt; " ";
      timeFound();
      cout &lt;&lt; flush;
    }
  }
  </code></pre>
  
  <p>As asked in comments, this is an example of the C++ output (from the line <code>Aug 17....</code> to <code>opengl support available</code> are only printed at program start and are not printed again.</p>
  
  <pre><code>Aug 17, 2015 11:57:03 AM com.layers.Main main
  INFO: Logger Created.
  Please enter activity number: 
  1.1
  VIDIOC_QUERYMENU: Invalid argument
  VIDIOC_QUERYMENU: Invalid argument
  VIDIOC_QUERYMENU: Invalid argument
  VIDIOC_QUERYMENU: Invalid argument
  VIDIOC_QUERYMENU: Invalid argument
  VIDIOC_QUERYMENU: Invalid argument
  VIDIOC_QUERYMENU: Invalid argument
  VIDIOC_QUERYMENU: Invalid argument
  VIDIOC_QUERYMENU: Invalid argument
  VIDIOC_QUERYMENU: Invalid argument
  VIDIOC_QUERYMENU: Invalid argument
  VIDIOC_QUERYMENU: Invalid argument
  VIDIOC_QUERYMENU: Invalid argument
  VIDIOC_QUERYMENU: Invalid argument
  init done 
  opengl support available 
  tap 2015-08-17 11:57:07
  kitchenDoor 2015-08-17 12:57:07
  fridge 2015-08-17 13:57:07
  </code></pre>
  
  <p>Also if I comment out the line beginning to the end of the scope:</p>
  
  <pre><code>String regEx...
  ...
  }
  </code></pre>
  
  <p>The Java program outputs as expected to the terminal but I've had to comment out the database upload to test this so I cannot verify if the upload works.</p>