StringBuffer class has a reverse() method that does excactly what you want.