| 47 | } |
| 48 | |
| 49 | public void run() { |
| 50 | byte boofer[] = new byte[256]; |
| 51 | |
| 52 | while (Thread.currentThread() == thread) { |
| 53 | try { |
| 54 | // can't use a buffered reader here because incremental |
| 55 | // print statements are interesting too.. causes some |
| 56 | // disparity with how System.err gets spewed, oh well. |
| 57 | int count = input.read(boofer, 0, boofer.length); |
| 58 | if (count == -1) { |
| 59 | thread = null; |
| 60 | |
| 61 | } else { |
| 62 | System.out.print(new String(boofer, 0, count)); |
| 63 | //System.out.flush(); |
| 64 | } |
| 65 | |
| 66 | } catch (IOException e) { |
| 67 | // this is prolly because the app was quit & the stream broken |
| 68 | //e.printStackTrace(System.out); |
| 69 | //e.printStackTrace(); |
| 70 | thread = null; |
| 71 | |
| 72 | } catch (Exception e) { |
| 73 | //System.out.println("SystemOutSiphon: i just died in your arms tonight"); |
| 74 | // on mac os x, this will spew a "Bad File Descriptor" ex |
| 75 | // each time an external app is shut down. |
| 76 | //e.printStackTrace(); |
| 77 | thread = null; |
| 78 | //System.out.println(""); |
| 79 | } |
| 80 | //System.out.println("SystemOutSiphon: out"); |
| 81 | //thread = null; |
| 82 | } |
| 83 | } |
| 84 | } |