麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 學院 > 開發設計 > 正文

[實例]JAVA生成字母+隨機數字并生成文件

2019-11-14 15:26:19
字體:
來源:轉載
供稿:網友
package com.ishow.control.code;import java.io.*;import java.text.SimpleDateFormat;import java.util.Random;/** * @author Lee * @version 創建時間:Oct 9, 2015 4:12:25 PM */        public class CreateCodeController{    /**     * 生成兌換碼     * @return     * @throws IOException      */    public static void main(String[] args){                Long start = System.currentTimeMillis();                String PRefix = "LF";    //前綴         int num = 10;//數字位數         int count = 10000;//生成數量         SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH時mm分");                //生成文件地址         File f = new File("C://Documents and Settings//Administrator//桌面//生成碼" + formatter.format(System.currentTimeMillis()) + ".txt");                OutputStreamWriter writer = null;        BufferedWriter bw = null;                Random random = new Random();        try {            OutputStream os = new FileOutputStream(f);            writer = new OutputStreamWriter(os);            bw = new BufferedWriter(writer);            int i=0;            while(i<count){                String str = "";                for (int j = 0; j < num; j++) {                    int number = random.nextInt(10);                          str+=number+"";                }                str = prefix+str;                try {                    bw.write(str+"/r/n");                } catch (Exception e) {                    i--;                }              i++;            }            bw.flush();        } catch (FileNotFoundException e) {            e.printStackTrace();        } catch (IOException e) {            e.printStackTrace();        } finally {            try {                bw.close();            } catch (IOException e) {                e.printStackTrace();            }        }        Long end = System.currentTimeMillis();        System.out.println("bufferedWrite And FileWriterTest's time---------" + (start - end)/1000d);    }}


 


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 中文字幕视频在线播放 | 久久国产经典 | 91成人免费网站 | 毛片118极品美女写真 | 久久久久久久爱 | 久久久久久久亚洲视频 | 色网站在线免费观看 | 久久新网址| 在线观看中文字幕av | japan护士性xxxⅹhd | 在线观看91精品 | 91精品国产乱码久久桃 | 中文字幕四区 | 国产精品成人久久 | 亚洲精品动漫在线观看 | 一级在线 | 欧美日本一 | 久久草在线视频免费 | 欧美一级二级毛片视频 | 日本黄色一级电影 | 亚洲福利视 | av免费在线观看国产 | 欧洲成人在线视频 | xnxx18日本| 午夜精品老牛av一区二区三区 | 羞羞的 | 2018亚洲男人天堂 | 精品成人免费一区二区在线播放 | 国产流白浆高潮在线观看 | av在线在线 | 亚州综合 | 成人综合一区二区 | av手机在线电影 | 97porn| 羞羞网站视频 | 中文字幕亚洲欧美 | 免费看国产 | 成人电影毛片 | 一级毛片免费高清视频 | 午夜小电影 | 国产成人高潮免费观看精品 |