首页 > 其他 > 详细

File 随笔 ( 1 )

时间:2015-06-06 01:34:55      阅读:158      评论:0      收藏:0      [点我收藏+]

package www.KINDA.com.cn.io;

import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;


public class FileDemo {
public static void main(String[] args) throws IOException {

//创建目录
File dir = new File("kinda");
if( !dir.exists() )
{
dir.mkdir();
}

//目录重命名
dir.renameTo(new File("susenne"));
//在当前目录下创建一个文件kinda.txt
File newFile = new File("susenne\\kinda.txt");
if( !newFile.exists() )
{
newFile.createNewFile();
}
newFile.renameTo(new File("susenne\\susenne.txt"));

//在当前工作目录创建文件
File file = new File("."+File.separator+"kinda.txt");
if( !file.exists() )
{
file.createNewFile();
file.getPath();
file.getAbsolutePath();
file.getCanonicalPath();
file.getAbsoluteFile();
file.getCanonicalFile();
file.getName();
}
new SimpleDateFormat("yyyy年MM月dd日, HH:mm:ss").format(new Date(file.lastModified()));
}
}

File 随笔 ( 1 )

原文:http://www.cnblogs.com/kindasusenne/p/4555853.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!