在File类中有这样两个方法:
isFile() ------- isDirectory()按我的理解,不是目录当然就是文件咯。为什么还要两个方法来判断了。其中isFile方法的doc给出一段话:
A file is normal if it is not a directory and, in addition, satisfies other system-dependent criteria. Any non-directory file created by a Java application is guaranteed to be a normal file.但我还是不明白,什么是normal文件?
isFile() ------- isDirectory()按我的理解,不是目录当然就是文件咯。为什么还要两个方法来判断了。其中isFile方法的doc给出一段话:
A file is normal if it is not a directory and, in addition, satisfies other system-dependent criteria. Any non-directory file created by a Java application is guaranteed to be a normal file.但我还是不明白,什么是normal文件?
system+hide+readonly 的文件可能检测不出来@_@
假如你认为!isA()则B,那也依然可以有个isB()方法
也许在isB的方法定义就是return !isA()呢?
只有当非目录File是由application创造出来实际有的文件的isFile()才是true,也就是说:
File aa = new File("C:\\asdfas.asd");
System.out.println(aa.isDirectory());
System.out.println(aa.isFile());
其中asdfas.asd是随手写的路径,这个时候,两句输出都是false.
isDirectory()
都是文件的属性。如果文件不存在根本不会去检测文件的这些属性。java只是对操作系统API的封装.检测一个不存在 或 存在 的文件和java本身根本没关系.检测一个存在文件的属性和java本身也根本没关系.所以你应该问操作系统是不是有重复问题? 不应该落在java上.normal file是针对操作系统的。你的native的返回是normal file,java当然就认为是normal file, 你想找到这种non-normal的文件必须用操作系统的API去找.所以你必须找一个能返回 0x01或大于等于0x09的文件.