title: Outputting batch file to JTextArea
body: <p>I have some code set up that is supposedly running the batch file. I'm not sure though because it's not showing anything in the console, but when I click the JButton PING, the button holds in the click for a couple seconds so it's definitely processing something. What I need help with is outputting the batch file to a JTextArea in my GUI. I'm not really sure how to direct my code to my JTextArea called "textarea". Can someone show me how you would add textarea into this code to get the output? Thanks!</p>
  
  <pre><code>JButton btnPingComputer = new JButton("PING");
      btnPingComputer.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
              try {
                     // create a new process
                   // System.out.println("Creating Process...");
                     Process p = Runtime.getRuntime().exec("c:\\ping.bat");
  
                     // get the input stream of the process and print it
                     InputStream in = p.getInputStream();
                     for (int i = 0; i &lt; in.available(); i++) {
                     System.out.println("" + in.read());
                     }
                     for (int i = 0; i &lt; in.available(); i++) {
                          textArea.append(in.read()+"\n");
                      }
                     // wait for 10 seconds and then destroy the process
  
                     p.destroy();
  
                     } catch (Exception ex) {
                     ex.printStackTrace();
                     }
  
  
  
  
          }
      });
  </code></pre>