Simplify statement by calling substring on str directly. StringUtils.startsWith makes sure that str is not null at this point. Improvement suggested by sebb.