public static String createStringCode(boolean numberFlag, int length) { String retStr = ""; String strTable = numberFlag ? "1234567890" : "1234567890abcdefghijkmnpqrstuvwxyz"; int len = strTable.length(); retStr = ""; for (int i = 0; i < length; i++) { double v = Math.random() * len; logger.info(v+"------"); retStr += strTable.charAt((int)Math.floor(v)); } return retStr; }