Android Random String Create randomAlphaNumeric(int length)

Here you can find the source of randomAlphaNumeric(int length)

Description

random Alpha Numeric

License

Open Source License

Declaration

public static String randomAlphaNumeric(int length) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Created by Carlos Yaconi/*from  w ww . j a  v a  2s .c  o  m*/
 * Copyright 2012 Fork Ltd. All rights reserved.
 * License: GPLv3
 * Full license at "/LICENSE"
 ******************************************************************************/

public class Main {
    public static String randomAlphaNumeric(int length) {
        StringBuffer buffer = new StringBuffer();
        String characters = "abcdefghijklmnopqrstuvwxyz0123456789";
        int charactersLength = characters.length();

        for (int i = 0; i < length; i++) {
            double index = Math.random() * charactersLength;
            buffer.append(characters.charAt((int) index));
        }
        return buffer.toString();
    }
}

Related

  1. randomIVString()
  2. getRandomString()
  3. getRandomPwd()
  4. genRandomString(int pLength)
  5. generateRandom()