package cn.itcast_06;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;
/*
 * 获取功能:
 *     public String getAbsolutePath():获取绝对路径
 *     public String getPath():获取相对路径
 *     public String getName():获取名称
 *     public long length():获取长度。字节数
 *     public long lastModified():获取最后一次的修改时间,毫秒值
 */
public class FileDemo {
  public static void main(String[] args) {
    // 创建文件对象
    File file = new File("demo\\test.txt");
    // 获取绝对路径
    System.out.println("getAbsolutePath:" + file.getAbsolutePath());
    // 获取相对路径
    System.out.println("getPath:" + file.getPath());
    // 获取名称
    System.out.println("getName:" + file.getName());
    // 获取长度。字节数
    System.out.println("length:" + file.length());
    // 获取最后一次的修改时间
    System.out.println("lastModified:" + file.lastModified());
    // 1484922361424
    Date date = new Date(1484922361424L);
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    String str = sdf.format(date);
    System.out.println(str);
  }
}