Android examples for java.util:Random
append In Between Random Space
import java.util.Random; public class Main{ public static String appendInBetweenRandomSpace(String string) { String spaces = " "; Random random = new Random(); int randomNum = random.nextInt(10); for (int index = 0; index < randomNum; index++) spaces = spaces + " "; if (string.contains(" ")) { int t = string.indexOf(" "); string = string.substring(0, t) + spaces + string.substring(t + 1); }//from w ww . ja v a 2 s . c o m return string; } }