Java5 conversion, generate less garbage for operations matching append.*substring