@ Override public StringBuilder appendToBuffer ( StringBuilder buf ) { String processedString = Integer . toString ( getProcessed ( ) ) ; int percentage = ( int ) ( getProcessed ( ) * 100.0 / total ) ; buf . append ( getTask ( ) ) ; buf . append ( ": " ) ; for ( int i = 0 ; i < totalLength - processedString . length ( ) ; i ++ ) { buf . append ( ' ' ) ; } buf . append ( getProcessed ( ) ) ; buf . append ( " [" ) ; if ( percentage < 100 ) { buf . append ( ' ' ) ; } if ( percentage < 10 ) { buf . append ( ' ' ) ; } buf . append ( percentage ) ; buf . append ( "%]" ) ; if ( ratems > 0. && getProcessed ( ) < total ) { buf . append ( ' ' ) ; int secs = ( int ) Math . round ( ( total - getProcessed ( ) ) / ratems / 1000. + .2 ) ; if ( secs > 300 ) { buf . append ( secs / 60 ) ; buf . append ( " min remaining" ) ; } else { buf . append ( secs ) ; buf . append ( " sec remaining" ) ; } } return buf ; }
Append a string representation of the progress to the given string buffer .