Empty directory: Difference between revisions
Content added Content deleted
(+Java 7) |
m (→{{header|Java}}: before anyone asks) |
||
Line 5: | Line 5: | ||
=={{header|Java}}== |
=={{header|Java}}== |
||
{{works with|Java|7+}} |
{{works with|Java|7+}} |
||
This method does not check that the path given is actually a directory. If a path to a normal file is given, it will throw a <code>NullPointerException</code>. |
This method does not check that the path given is actually a directory. If a path to a normal file is given, it will throw a <code>NullPointerException</code>. <code>File.listLess()</code> does not count the "." and ".." entries. |
||
<lang java5>import java.nio.file.Paths; |
<lang java5>import java.nio.file.Paths; |
||
//... other class code here |
//... other class code here |
||
Line 11: | Line 11: | ||
return Paths.get(dirName).toFile().listFiles().length == 0; |
return Paths.get(dirName).toFile().listFiles().length == 0; |
||
}</lang> |
}</lang> |
||
=={{header|Ruby}}== |
=={{header|Ruby}}== |
||
{{works with|Ruby|1.8.7}} |
{{works with|Ruby|1.8.7}} |