title: How to test if PrintWriter / OutputStreamWriter / BufferedWriter / OutputStream is working?
body: <p>With terminal I type <code>chiplotle</code> and after that I type <code>11</code>.
  This is how the terminal looks after that:
  <img src="https://i.stack.imgur.com/S8C4N.png" alt="enter image description here"></p>
  
  <p>I want to do the same thing in java but i'm stuck with the eleven options part.
  I know when it happens and I print a <code>11</code> but nothing happens after that.</p>
  
  <p>It might be in this part.</p>
  
  <pre><code>if (line.equals("[11] Plotter")) {
    System.out.println("---!!!---"); // it does print this!
    pw.println("11"); // tried multiple things
    pw.println("or give me at least an error...");
  }
  </code></pre>
  
  <p>But i'm afraid my print writer is wrong. How can I test this?</p>
  
  <pre><code>import java.io.*;
  
  
  public class ExecTest {
  
      ChiplotleInputStream chiplotleInputStream;
      ChiplotleErrorStream chiplotleErrorStream;
  
      PrintWriter pw;
  
      public static void main(String[] args) {
  
          new ExecTest().setup();
  
      }
  
  
      // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  
  
      public void setup() {
  
          try {
              Runtime runTime = Runtime.getRuntime();
  
              Process process = runTime.exec("chiplotle");
  
              chiplotleInputStream = new ChiplotleInputStream(process);
              chiplotleErrorStream = new ChiplotleErrorStream(process);
  
              OutputStream os = process.getOutputStream();
              BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(os));
              pw = new PrintWriter(bw);
  
              new Thread(chiplotleInputStream).start();
              new Thread(chiplotleErrorStream).start();
  
  
  //            process.destroy();
  
          }
          catch (IOException e) {
              e.printStackTrace();
          }
  
      }
  
  
      // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  
  
      public class ChiplotleInputStream implements Runnable {
  
          BufferedReader in;
  
          public ChiplotleInputStream(Process process) {
              in = new BufferedReader(new InputStreamReader(process.getInputStream()));
          }
  
          @Override
          public void run() {
  
              String line;
  
              try {
                  while ((line = in.readLine()) != null) {
  
                      System.out.println(line);
  
                      if (line.equals("[11] Plotter")) {
                          System.out.println("---!!!---"); // it does print this!
                          pw.println("11\r\n"); // tried multiple things
                          pw.println("or give me at least an error...");
                      }
  
  
                  }
              } catch (Exception e) {
                  e.printStackTrace();
              }
  
          }
      }
  
  
       // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  
  
       public class ChiplotleErrorStream implements Runnable {
  
           BufferedReader in;
  
           public ChiplotleErrorStream(Process process) {
               in = new BufferedReader(new InputStreamReader(process.getErrorStream()));
           }
  
           @Override
           public void run() {
  
               String line;
  
               try {
                   while ((line = in.readLine()) != null) {
                       System.out.println(line);
                   }
               } catch (Exception e) {
                   e.printStackTrace();
               }
  
           }
       }
  
      // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  
  
  }
  </code></pre>