是系统文件,偶机子里没有hiberfil.sys。 File f = new File("c:\\PAGEFILE.SYS"); System.out.println(f.isFile()); 亦是false。 返回false不代表是目录。 true if and only if the file denoted by this abstract pathname exists and is a normal file; false otherwise It's a system file。
谢谢ntzls。你的提醒很对。我做了以下的实验: public static void main(String[] args) { File f = new File("c:\\hiberfil.sys"); System.out.println(f.isFile());//false System.out.println(f.isDirectory());//also false }同样的问题发生在 "C:\System Volume Information\" 和 "E:"(假设E盘是你的光驱,而你的光驱此时刚好没有光盘在里面)。我归纳了一下,大概是这样: 1.Windows会“Lock”住个别文件或是文件夹,此时Administrator也没有办法访问它们。 2.对于1中的文件,虽然用File.listFiles()能够获得它,但是File.isFile()和File.isDirectory()均返回false。 3.对于1中的文件夹,虽然用File.listFiles()能够获得它,且File.isDirectory()返回true,但是对它运用listFile()仍然会返回null。希望大家指正啦。:)
关于File.isFile方法,在Java doc中有详细的说明.它的返回值是这样的:Returns: true if and only if the file denoted by this abstract pathname exists and is a normal file; false otherwise
File f = new File("c:\\PAGEFILE.SYS");
System.out.println(f.isFile());
亦是false。
返回false不代表是目录。
true if and only if the file denoted by this abstract pathname exists and is a normal file; false otherwise It's a system file。
public static void main(String[] args)
{
File f = new File("c:\\hiberfil.sys");
System.out.println(f.isFile());//false
System.out.println(f.isDirectory());//also false
}同样的问题发生在 "C:\System Volume Information\" 和 "E:"(假设E盘是你的光驱,而你的光驱此时刚好没有光盘在里面)。我归纳了一下,大概是这样:
1.Windows会“Lock”住个别文件或是文件夹,此时Administrator也没有办法访问它们。
2.对于1中的文件,虽然用File.listFiles()能够获得它,但是File.isFile()和File.isDirectory()均返回false。
3.对于1中的文件夹,虽然用File.listFiles()能够获得它,且File.isDirectory()返回true,但是对它运用listFile()仍然会返回null。希望大家指正啦。:)
true if and only if the file denoted by this abstract pathname exists and is a normal file; false otherwise