question: void readStream ( InputStream is ) throws Exception { String line ; Date start = new Date ( ) ; BufferedReader reader = new BufferedReader ( new InputStreamReader ( is ) ) ; while ( ( line = reader . readLine ( ) ) != null && ! mStop ) { mResults . append ( line ) ; mResults . append ( Tools . LineSep ) ; Date end = new Date ( ) ; if ( ( end . getTime ( ) - start . getTime ( ) ) / 1000 > 10 || mResults . length ( ) > 5000 ) { start = end ; int last = mResults . lastIndexOf ( "\n" ) ; if ( last != - 1 ) { XmppMsg msg = new XmppMsg ( _font ) ; msg . append ( mResults . substring ( 0 , last + 1 ) ) ; mCmdBase . send ( mShellId , msg ) ; mResults . setLength ( 0 ) ; } } } }
target:  Reads the given InputStream and sends a XmppMsg every 5000 chars or every 10 seconds, whatever comes first. If we happen to encounter an InputStream that never stops, like from "tail -f" or "logcat" without the "-d" option, the method will never  return. See executeCommand on how we handle this.