Java根据日期动态创建文件夹

如下示例代码为在E盘的根目录下创建日期格式(精确到天)的文件夹,并在该文件夹中创建一个txt文件。
        Date date = new Date(); 
	String path="E:/"+new SimpleDateFormat("yyyy/MM/dd/").format(date);
	//如果不存在,创建文件夹
	File f = new File(path);
	if(!f.exists()){
	    f.mkdirs(); 
	}
	OutputStream out;
	UUID uuid = UUID.randomUUID();
	String fileName = uuid + ".txt";
	out = new FileOutputStream(path + fileName);
	out.flush();
	out.close();


你可能感兴趣的:(java,Java)