public static Callable < String > getCallWTimeout ( BufferedReader reader , int timeout , HasPrompt emptyPrint ) { return new Callable < String > ( ) { @ Override public String call ( ) throws IOException { String ret = "" ; while ( "" . equals ( ret ) ) { try { while ( ! reader . ready ( ) ) { Thread . sleep ( timeout ) ; } ret = reader . readLine ( ) ; if ( "" . equals ( ret ) && emptyPrint != null ) { System . out . print ( emptyPrint . prompt ( ) ) ; } } catch ( InterruptedException e ) { return null ; } } return ret ; } } ; }
Returns a new callable for reading strings from a reader with a given timeout .