import java.io.File;
import java.io.IOException;
class Filetest
{
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.getAbsoluteFile());
System.out.println("file.getAbsolutefile().getParent()");
File tmpFile = File.createTempFile("aaa",".txt",file);
tmpFile.deleteOnExit();
File newFile = new File(System.currentTimeMillis() + "");
System.out.println("newFile对象是否存在: " + newFile.exists());
newFile.createNewFile();
newFile.mkdir();
String[] fileList = file.list();
System.out.println("====当前路径下所有文件和路径如下====");
for (String filename:filelist)
{
System.out.println("fileName");
}
File[] roots = File.listRoots();
System.out.println("====系统所有根路径如下====");
for (File root : roots)
{
System.out.println(root);
}
}
}
编译时出错
d:\>javac -d .1.java
1.java:41:错误:找不到符号
for(String filename:filelist)
符号:变量filelist
位置:类filetest
1个错误