zoukankan      html  css  js  c++  java
  • java造测试数据

    
    

    import java.io.File;
    import java.io.FileWriter;
    import java.io.IOException;
    import java.util.List;
    import java.util.Random;

    import static java.util.Arrays.asList;

    public class test01 {
    public static void main(String[] args) {
    File file = null;
    FileWriter fw = null;
    file = new File("D:\temp\helloWord.txt");
    List<String> area=asList("山西","河南","湖北","北京") ;
    List<String> sex=asList("女","男") ;

    try {
    if (!file.exists()) {
    file.createNewFile();
    }
    fw = new FileWriter(file);
    for(int i = 1;i <=1000;i++){
    Random r = new Random();
    //获取0-9之间的随机数
    int number = r.nextInt(4);
    int sex01=r.nextInt(2);
    fw.write(area.get(number)+","+sex.get(sex01)+","+i+" ");//向文件中写入内容
    fw.flush();
    }
    } catch (IOException e) {
    e.printStackTrace();
    }finally{
    if(fw != null){
    try {
    fw.close();
    } catch (IOException e) {
    e.printStackTrace();
    }
    }
    }
    }
    }

     
    RUSH B
  • 相关阅读:
    ES6介绍
    django-缓存
    Python标准模块--functools
    python-深浅拷贝
    Django专题-ugettext_lazy
    PHP 连接 MySQL
    PHP 过滤器
    PHP session
    PHP cookie
    PHP 文件上传
  • 原文地址:https://www.cnblogs.com/tangsonghuai/p/12659313.html
Copyright © 2011-2022 走看看