package IODemo;
import java.io.*;
import java.util.*;
public class TestFileOBJ {
public void FileInformation(File f){
System.out.println("getName="+f.getName());
System.out.println("getPath="+f.getPath());
System.out.println("getAbsolutePath="+f.getAbsolutePath());
System.out.println("getParent="+f.getParent());
System.out.println("length="+f.length());
System.out.println("lastModified="+new Date(f.lastModified()));
}
public void DirectoryInformation(File d){
System.out.println("Dir.getName="+d.getName());
System.out.println("Dir.getParent="+d.getParent());
int i=0;
String it[]=d.list();//列出文件与子目录
while(i<it.length){
System.out.println("Files="+it[i]);
i++;
}
}
public static void main(String[] args){
File f=new File("E://IOdemo","Fileln.java");
File d=new File("E://IOdemo//IOdemo");
File d1=new File("E://IOdemo//Demo01");
TestFileOBJ fo=new TestFileOBJ();
System.out.println("File.information:"+f.getAbsolutePath());
System.out.println("================================");
fo.FileInformation(f);
System.out.println("================================");
System.out.println("Directory information:E:\\javalianxi\\Bark");
System.out.println("================================");
fo.FileInformation(d);
fo.DirectoryInformation(d);
System.out.println("================================");
d1.mkdir();
}
}