Io NIO 操作
第一。
操作
package zdian;
import java.io.File;
public class Piede {
public static void main(String[] args) {
File f= new File("D:\\java");
File[] fs = f .listFiles();
for(File a: fs ) {
String n =a.getName();
if(a.isFile()) {
System.out.println(a + "文件");
System.out.println(a.length());
System.out.println(a.getParent());
System.out.println(a.getAbsolutePath());
System.out.println(a.lastModified());
}else {
System.out.println(a+"目录");
}
}
}
File f= new File("D:\\java");
File[] fs = f .listFiles();
for(File a: fs ) {
String n =a.getName();
if(a.isFile()) {
System.out.println(a + "文件");
System.out.println(a.length());
System.out.println(a.getParent());
System.out.println(a.getAbsolutePath());
System.out.println(a.lastModified());
}else {
System.out.println(a+"目录");
}
}
}
}
输出结果