Java获取随机的流水号(10位)

/**
     * 获取随机的流水号(10位)
     * @return
     */
     public static String getRandomReqNo() {
          int length=10;
         String base = "abcdefghijklmnopqrstuvwxyz0123456789";  
         Random random = new Random();  
         StringBuffer sb = new StringBuffer();  
         for (int i = 0; i < length; i++) {  
             int number = random.nextInt(base.length());  
             sb.append(base.charAt(number));  
         }  
         return sb.toString();  
     }   

 

posted @ 2016-04-04 10:45  guaidaoK的博客  阅读(5000)  评论(0编辑  收藏  举报