public static String format ( String template , Object ... args ) { String [ ] templateArr = TEMPLATES . get ( template ) ; if ( templateArr == null ) { // we may have a race condition here but the end result is idempotent templateArr = prepareTemplate ( template ) ; TEMPLATES . put ( template , templateArr ) ; } StringBuilder sb = new StringBuilder ( template . length ( ) * 2 ) ; for ( int i = 0 ; i < templateArr . length ; i ++ ) { sb . append ( templateArr [ i ] ) ; if ( args != null && ( i < templateArr . length - 1 ) ) { sb . append ( ( i < args . length ) ? args [ i ] : TOKEN ) ; } } return sb . toString ( ) ; }
no escaping is supported no array content printing either .