java - Apache DefaultExecutor and Ping command for JTextArea -


i newbie in java apache utilities.

i studying apache's defaultexecutor method following code.


import java.io.bufferedreader; import java.io.ioexception; import java.io.inputstreamreader;  import org.apache.commons.exec.commandline; import org.apache.commons.exec.defaultexecuteresulthandler; import org.apache.commons.exec.defaultexecutor; import org.apache.commons.exec.executeexception; import org.apache.commons.exec.logoutputstream; import org.apache.commons.exec.pumpstreamhandler;  public class pingexampleapacheexec {      public static void main(string[] args) {         //           commandline commandline = new commandline("ping");         commandline.addargument("/n");         commandline.addargument("5");         commandline.addarguments("/w 1000");         commandline.addargument("127.0.0.1");          // executor         defaultexecutor executor = new defaultexecutor();         try {               // logoutputstream              logoutputstream output = new logoutputstream() {                 @override                 protected void processline(string line, int level) {             //         newjframe1 mylog = new newjframe1();   // not worked            //         mylog.mainlog();                       // not worked            //         mylog.jtextarea1.settext(line);        // not worked                       system.out.println(line);                 }             };             pumpstreamhandler streamhandler = new pumpstreamhandler(output);             executor.setstreamhandler(streamhandler);               executor.setexitvalue(0);               defaultexecuteresulthandler resulthandler = new defaultexecuteresulthandler();             executor.execute(commandline, resulthandler);              // todo output.close()           } catch (executeexception ex) {             ex.printstacktrace();         } catch (ioexception ex) {             ex.printstacktrace();         }     } } 

==========================

my simple question: above code working, failed when redirect string jtextarea.

how can it? i.e. how print ping info jtextarea? why settext/append didn't work?

i see settext() , append() no longer thread-safe since java 7.


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -