There is a RandomStringUtils class in apache common package