zoukankan      html  css  js  c++  java
  • 创建随机的文件

    package File;
    
    import java.io.IOException;
    
    //创建随机的文件
    public class FileCreade {
        public static void main(String args[]) throws IOException{
            int MaxFile=Integer.parseInt(args[0]);
            String Path=args[1];
    //        int MaxFile=10;
    //        String Path="C:/df/";
            for(int i=0;i<MaxFile;i++){
                int Length=10;
                int LastLength=3;
                String Name=new GreadName(Length).Name;
                String LastName=new GreadName(LastLength).Name;
                String FName=Path+Name+"."+LastName;
                new GreadFile(FName);
            }
        }
    }
    package File;
    
    import java.io.BufferedWriter;
    import java.io.File;
    import java.io.FileWriter;
    import java.io.IOException;
    
    public class GreadFile {
        public GreadFile(String fName) throws IOException {
            // TODO Auto-generated constructor stub
            try{
                File NewFile=new File(fName);
                FileWriter wt=new FileWriter(NewFile,true);
                BufferedWriter bw=new BufferedWriter(wt);
                bw.close();
            }catch(IOException e){
                e.printStackTrace();
            }
        }
    }
    package File;
    
    public class GreadName {
        public static String Name=null;
        public GreadName(int length) {
            // TODO Auto-generated constructor stub
            char[] s = new char[length];
            for(int i=0;i<s.length;i++){
                int f=(int)(Math.random()*3);
                if(f==0)
                    s[i]= (char) (('A')+Math.random()*26);
                if(f==1)
                    s[i]= (char) (('a')+Math.random()*26);
                if(f==2)
                    s[i]= (char) (('0')+Math.random()*10);
            }
            Name=new String(s);
        }    
    }
  • 相关阅读:
    2021.4.2 Python基础及介绍
    2021.4.1 团队组队
    冲击信号
    信号卷积(线性卷积)
    数字图像处理基本概念
    计算机视觉发展及主要研究方向
    SVM 之 SMO 算法
    FP Growth 算法
    Apriori 算法
    26 实战页式内存管理 下
  • 原文地址:https://www.cnblogs.com/leonxiaosi/p/2892824.html
Copyright © 2011-2022 走看看