antonpp antonpp - 1 year ago 107
Java Question

Java nio. Empty path

Can anyone tell me where

points to?

Here is the code and the output.

public static void main(String[] args) {
Path path = Paths.get("");
System.out.printf("`%s`%n", path);
System.out.printf("`%s`%n", path.normalize());


Answer Source


Looks like it's the current working directory. On my machine, Java is reporting that it's executable because the 'x' flag on the directory is true for the current user.

From the javadocs:

This method checks that a file exists and that this Java virtual machine has appropriate privileges to execute the file. The semantics may differ when checking access to a directory. For example, on UNIX systems, checking for execute access checks that the Java virtual machine has permission to search the directory in order to access file or subdirectories.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download