java修改文件的名称_Java修改文件名称
import java.io.File;
import java.io.IOException;
public class Rename {
public static void main(String[] args) throws IOException
{
File oldFile = new File("d:/1.Out");
if(!oldFile.exists())
{
oldFile.createNewFile();
}
System.out.println("修改前:"+oldFile.getName());
String rootPath = oldFile.getParent();
System.out.println("根路徑是:"+rootPath);
File newFile = new File(rootPath + File.separator + "1.Out.back");
System.out.println("修改后:"+newFile.getName());
if (oldFile.renameTo(newFile))
{
System.out.println("修改成功!!!");
}
else
{
System.out.println("修改失敗!!!");
}
}
}
原文:http://8757576.blog.51cto.com/8747576/1615208
總結
以上是生活随笔為你收集整理的java修改文件的名称_Java修改文件名称的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python抽取某个时间段的数据_pyt
- 下一篇: 请输入汉字、英文、数字或其组合/请输入6