以下是主要程序:
String s="D:\\haha\\test\\dssa.txt";
File f=new File(s);
f.getParentFile().mkdirs();
try
{
f.createNewFile(); //新建文件
}catch(IOException e)
{
System.out.println("创建文件时出错:");
e.printStackTrace();
}
File f1=new File("D:\\haha\\test\\mm.txt");
f.renameTo(f1);
System.out.println("文件重命名为:"+f.getName())
白衣非少年
相关分类