默认目录创建指定类型的文件

在默认目录创建.txt文件

import java.io.*;
public class CreateTxtFile extends Exception{
	public static void main(String[] args){
		for(int i = 1;i<100;i++){
			File file = new File(i+".txt");
			try{
				if(!file.exists()){
					file.createNewFile();
				}
			}catch(IOException e){
					e.printStackTrace();
				}
	}

	}
}

posted @ 2021-07-06 13:47  withLevi  阅读(39)  评论(0编辑  收藏  举报