title: I just write a wrapcommand in java but sometimes it do not print the command output. WHY
body: <p>I just write a simple commandwrapper in java, this is construction function:</p>
  
  <pre><code>Process process;
  Thread in;
  Thread out; 
  
  public CommandWrapper(Process process) {
      this.process = process;
      final InputStream inputStream = process.getInputStream();
      // final BufferedReader
      //final BufferedReader r = new BufferedReader(new InputStreamReader(inputStream));
      final byte[] buffer = new byte[1024];
      out = new Thread() {
          // String line;
          int lineNumber = 0;
  
          public void run() {
              try {
                  while (true) {
                      int count = inputStream.read(buffer);
                      System.out.println(lineNumber + ":"
                              + new String(buffer, 0, count - 1));
                      // line=r.readLine();
                      // System.out.println(lineNumber+":"+line);
                      lineNumber++;
                  }
              } catch (Exception e) {
  
              }
          }
      };
      final BufferedReader reader = new BufferedReader(new InputStreamReader(
              System.in));
      final OutputStream outputStream = process.getOutputStream();
      in = new Thread() {
          String line;
  
          public void run() {
              try {
                  //while (true) {
                      outputStream.write((reader.readLine() + "/n")
                              .getBytes());
                      outputStream.flush();
                  //}
              } catch (Exception e) {
  
              }
          }
      };
  }
  
  public void startIn() {
      in.start();
  }
  </code></pre>
  
  <p>This is when it invoke:</p>
  
  <pre><code>public static void main(String[] args) {
      try {
          CommandWrapper command = new CommandWrapper(Runtime.getRuntime()
                  .exec("wget www.google.com"));
          //command.startIn();
          command.startOut();
      } catch (Exception e) {
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <p>It works OK when I run simple command like ls -l or other local commander, but when I want to run wget command it is print out nothing as output. I do know why.</p>