package com.companyname.common.test; import java.io.File; import java.util.Date; /** * @author shusheng * @description * @Email shusheng@yiji.com * @date 2018/10/15 16:49 */ public class FileDemo6 { /**获取功能: *public String getAbsolutePath():获取绝对路径 *public String getPath():获取相对路径 *public String getName():获取名称 *public long length():获取长度。字节数 *public long lastModified():获取最后一次的修改时间,毫秒值 */ public static void main(String[] args) { File file = new File("C:\Users\shusheng\Pictures\222.jpg"); 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:" + new Date(file.lastModified())); } }