学习笔记- 查看一个文件夹下的文件及文件夹,仿Windows资源管理器

来源:互联网 发布:姚笛和马伊琍 知乎 编辑:程序博客网 时间:2024/05/17 07:00
public static void main(String[] args) {// TODO Auto-generated method stubString path = "D:\\EA7.5\\";File file = new File(path);System.out.printf("文件\t\t\t\t大小\t类型\t修改日期\t","");SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");String[] flist = file.list();for(String s:flist){File file1 = new File(path+s);System.out.println(file1.getName()+file1.length()+"\t"+(file1.isDirectory()?"文件夹":"文件")+"\t"+sdf.format(new Date(file1.lastModified())));}}
排版没排好,表示不知道怎么排,只做笔记用
0 0
原创粉丝点击