private String selectRunningService ( ) { String selectedServiceId ; List < String > runningServiceIds = getRunningServiceIds ( ) ; for ( int i = 0 ; i < runningServiceIds . size ( ) ; i ++ ) { String serviceId = runningServiceIds . get ( i ) ; OutputStreamFormater . printTabbedValues ( 9 , String . format ( "[%s]" , i ) , String . format ( "%s" , serviceId ) ) ; } String s = readUserInput ( ) ; int pos ; try { pos = Integer . parseInt ( s ) ; selectedServiceId = runningServiceIds . get ( pos ) ; } catch ( Exception e ) { throw new IllegalArgumentException ( String . format ( "Invalid Input: %s" , s ) ) ; } return selectedServiceId ; }
let the user chose one of the running services