这是一张java应用教程的随书光盘
源代码在线查看: filetest1.java
import java.io.*;
class FileTest1
{
public static void main(String args[]){
System.out.println("path separater "+File.pathSeparator);
System.out.println("path separater char "+File.pathSeparatorChar);
System.out.println("separater "+File.separator);
System.out.println("separater char "+File.separatorChar);
File p=new File("c:/qq/");
File f=new File(p,"ReadMe.txt");
System.out.println();
System.out.println(f);
System.out.println("exist? "+f.exists());
System.out.println("name "+f.getName());
System.out.println("len "+f.length());
System.out.println("path "+f.getPath());
System.out.println("Parent "+f.getParent());
System.out.println("is a file "+f.isFile());
System.out.println("is a directory "+f.isDirectory());
System.out.println("can read "+f.canRead());
System.out.println("can write "+f.canWrite());
System.out.println("is modified "+f.lastModified());
File newFile=new File("Hello.txt");
f.renameTo(newFile);
System.out.println("original exist? "+f.exists());
System.out.println("new exist? "+newFile.exists());
System.out.println("newFile name "+newFile.getName());
System.out.println("Absolute path "+newFile.getAbsolutePath());
}
}