private String rightAlignedZero ( String s , int len ) { if ( len == s . length ( ) ) return s ; StringBuffer sb = new StringBuffer ( s ) ; while ( sb . length ( ) < len ) { sb . insert ( 0 , ' ' ) ; } return sb . toString ( ) ; }
Method to generate a string with a particular width . Alignment is done using zeroes if it does not meet the width requirements .