我正在尝试将当前日期时间附加到文件名并将其传递给文件的创建...所以基本上这是我的代码
public class Main {
//....
public static void main(String[] args) throws IOException
{
DateFormat dt = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
Date date = new Date();
String d =dt.format(date).toString();
String fname = "spy1";
File dir = new File("E:\\");
File f = new File(dir,fname+d+".txt");
if(f.createNewFile())
{
System.out.println("file creates");
}
else
{
System.out.println("file not created ");
}
}
}
这是我的代码,请帮助我如何将当前日期时间附加到文件名并使用提到的目录创建文件