import java.io.File; import java.text.SimpleDateFormat;

public class Main { public static void main(String[] args) { File file = new File('myfile.txt'); SimpleDateFormat sdf = new SimpleDateFormat('yyyy-MM-dd HH:mm:ss'); System.out.println('文件名:' + file.getName()); System.out.println('文件大小:' + file.length() + ' bytes'); System.out.println('最后修改时间:' + sdf.format(file.lastModified())); } }

Java 获取文件信息:文件名、大小和最后修改时间

原文地址: https://www.cveoy.top/t/topic/oXkC 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录