public void replaceChars ( int startPosition , int endPosition , String replacement ) { try { sourceBuilder . replace ( startPosition , endPosition , replacement ) ; } catch ( StringIndexOutOfBoundsException e ) { throw new IndexOutOfBoundsException ( String . format ( "Replacement cannot be made. Source file %s has length %d, requested start " + "position %d, requested end position %d, replacement %s" , path , sourceBuilder . length ( ) , startPosition , endPosition , replacement ) ) ; } }
Replace the source code between the start and end character positions with a new string .