</pre><pre name="code" class="java">public class StringUtils{ private static Random randGen = new Random(); private static char[] letters =("0123456789abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ").toCharArray(); //获取指定长度的随机字符串 public static String randomString(int len){ if(len<1){ return null; } char[] buf= new char[len]; for(int i=0;i<len;i++){ buf[i]=letters[randGen.nextInt(71)]; } return new String(buf); } // }