class="java"> import java.io.*; import java.util.*; public class TestFile { public static void main(String[] args) throws IOException { File file= new File("."); System.out.println(file.getName()); System.out.println(file.getParent()); System.out.println(file.getAbsolutePath()); File tempFile=file.createTempFile("aaa",".txt",file); tempFile.deleteOnExit(); File newFile= new File(System.currentTimeMillis()+""); System.out.println("newFile是否存在:"+newFile.exists()); newFile.createNewFile(); newFile.mkdir(); String[] strList = file.list(); System.out.println("-------------当前的路径下所有的文件盒路劲:---------------------"); for(String fileName:strList){ System.out.println(fileName); } System.out.println("-------------系统的根路径如下:-----------------------------:"); File[] roots=File.listRoots(); for(File root:roots){ System.out.println(root); } } }