java - redirecting console output of a compiled file to GUI -
i making application take input java program, compile , show output after running on screen in text box. not able figure out way redirect output of program onto screen. please me out.
try this:
process proc = processbuilder.start(); ctrl.clear(); reader = new bufferedreader(new inputstreamreader(proc.getinputstream())); while(true) { int exitvalue; try { proc.exitvalue(); system.out.println("process ended exit value "+ exitvalue); } catch(illegalthreadstateexception e) {// process alive try { final string str = reader.readline(); if (str!=null) { //print string somewhere } } catch(ioexception ignored) { } } }
edit: note have processes instance. how doesn't matter.
Comments
Post a Comment