1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| public String generateCodeElement()
throws ServiceException{
try{
//variables
String base = "abcdefghijklmnopqrstuvwxyz0123456789";
Random r = new Random();
char[] buffer = new char[10];
//balayage de la variable(tableau) de retour
for(int i=0;i<buffer.length;i++)
{ //recupération d'une valeur au pif dans la variable "base"
buffer[i] = base.charAt(r.nextInt(base.length()));
}
//création de la valeur de retour
return new String(buffer);
} catch (Exception e) {
throw new ServiceException(e);
}
} |