java生成字母首位8位随机码
public String getRedomchar(){
String[] char1 = new String[] { "a", "b", "c", "d", "e", "f",
"g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s",
"t", "u", "v", "w", "x", "y", "z", "0", "A", "B", "C", "D", "E", "F", "G", "H", "I",
"J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V",
"W", "X", "Y", "Z"};
String[] chars = new String[] { "a", "b", "c", "d", "e", "f",
"g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s",
"t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "5",
"6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I",
"J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V",
"W", "X", "Y", "Z","!", "@", "#", "$", "%", "^", "&", "*", "(", ")",
"_", "+", "-","=","`","~",",",".","<",">","/","?",":",";","'","\\","。","|"};
StringBuffer shortBuffer = new StringBuffer();
String random = "";
int index1 = (int) (Math.random() * char1.length);
random = char1[index1];
shortBuffer.append(random);
LogUtil.writeLog("第一个字母:"+shortBuffer);
for (int i = 1; i <=7; i++) {
int index = (int) (Math.random() * chars.length);
random = chars[index];
shortBuffer.append(random);
}
LogUtil.writeLog("拼成后的8个随机码:"+shortBuffer);
String suffix = shortBuffer.toString();
return suffix;
}
java生成字母首位8位随机码的更多相关文章
- JAVA 生成无重复8位随机码(转)
转载自:https://my.oschina.net/vvcumt/blog/491504 短8位UUID思想其实借鉴微博短域名的生成方式,但是其重复概率过高,而且每次生成4个,需要随即选取一个. 本 ...
- [实例]JAVA生成字母+随机数字并生成文件
package com.ishow.control.code; import java.io.*; import java.text.SimpleDateFormat; import java.uti ...
- Java生成前三位是字母循环的字典
title: Java生成前三位是字母循环的字典 date: 2018-08-17 18:52:22 tags: Java --- 最近要破解一个秘密,还好这个密码是有线索的,已知密码的前三位是三个字 ...
- 生成一个字母数字组合的n位随机码、随机数、随机字符串
package com.cms.util; /** * 生成一个字母数字组合的n位随机码 * @author abc * */ public class CodeUtil { // private f ...
- java 生成8位数字作为UID
java 生成8位数字作为UUID: /*** * 生成uid 8位数字 */public static String generateUID(){ Random random = new Rando ...
- java 生成20位唯一ID,生成不会重复的20位数字----https://blog.csdn.net/weixin_36751895/article/details/70331781
java 生成20位唯一ID,生成不会重复的20位数字----https://blog.csdn.net/weixin_36751895/article/details/70331781
- java生成32位UUID
java生成32位UUID,具体代码如下: package com.fxsen.uuid; import java.util.UUID; /** * Copyright: Copyright (c) ...
- C# 生成随机的6位字母,包含大小写
今天自己做项目需要生成随机的6位字母,于是自己写了一个,下面代码是可以生成任意位数字母的. string _zimu = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefg ...
- Java生成三位随机数
转: [转]Java生成三位随机数 public class Test2 { public static void main(String [] srgs) { int i=(int)(Math.ra ...
随机推荐
- R: 基本的数学运算
################################################### 问题:基本数学运算 18.4.30 R语言用于初等数学的计算,都怎么表示??加减乘除.余数. ...
- Evil Book -- CodeChef
传送门 分析 对于这道题,我们首先思考一个贪心策略,即对于所有我们要打败的厨师我们肯定可以先打败需使用帮助次数少的厨师再打败需使用帮助次数多的厨师 ,因为这样可以使得能支付得起帮助费用的可能性尽可能的 ...
- Luogu 2322 [HNOI2006]最短母串问题
唔,太菜了,弄了好几个小时. 状压dp,设$f_{s, i}$表示选了集合$s$,以$i$结尾的最短长度,设$g_{i, j}$表示串$i$的后缀和串$j$的前缀的最长匹配长度. $f_{s, i} ...
- thinkphp目录解析
- for与break的用法
# Auther: Aaron Fan age_of_oldboy = 56 #执行3次循环for i in range(3): guess_age = int(input("猜一下oldb ...
- oracle获取列的备注和数据类型
select column_name, data_type, data_precision, data_scale, nvl((select t_s.comments from all_col_com ...
- c++调用python引号的问题
Boost.Python向python里面传递字符串时,引号是个很关键的问题. const char* cstr="hello \\\" world" // hello ...
- Android 实现形态各异的双向侧滑菜单 自定义控件来袭(转载)
1.概述 关于自定义控件侧滑已经写了两篇了~~今天决定把之前的单向改成双向,当然了,单纯的改动之前的代码也没意思,今天不仅会把之前的单向改为双向,还会多添加一种侧滑效果,给大家带来若干种形态各异的双向 ...
- android加载字体内存泄漏的处理方法
在开发android app的开发过程中,会使用到外部的一些字体.外部字体在加载的时候,容易造成内存泄漏. 比如: Typeface tf=Typeface.createFromAsset(getAs ...
- SQL:bat批处理多个.sql文件
一.批处理文件 update.bat 设置sqlserver的实例 记得一定要配置logfile文件 @echo off :: #### B. #### set LOGFILE=& ...