43 * |
43 * |
44 * <p> The {@code Path} is obtained by invoking the {@link FileSystem#getPath |
44 * <p> The {@code Path} is obtained by invoking the {@link FileSystem#getPath |
45 * getPath} method of the {@link FileSystems#getDefault default} {@link |
45 * getPath} method of the {@link FileSystems#getDefault default} {@link |
46 * FileSystem}. |
46 * FileSystem}. |
47 * |
47 * |
|
48 * <p> Note that while this method is very convenient, using it will |
|
49 * imply an assumed reference to the default FileSystem and limit the |
|
50 * utility of the calling code. Hence it should not be used in library code |
|
51 * intended for flexible reuse. A more flexible alternative is to use an |
|
52 * existing {@code Path} instance as an anchor, such as: |
|
53 * <pre> |
|
54 * Path dir = ... |
|
55 * Path path = dir.resolve("file"); |
|
56 * </pre> |
|
57 * |
48 * @param path |
58 * @param path |
49 * The path string to convert |
59 * the path string to convert |
50 * |
60 * |
51 * @return The resulting {@code Path} |
61 * @return the resulting {@code Path} |
52 * |
62 * |
53 * @throws InvalidPathException |
63 * @throws InvalidPathException |
54 * If the path string cannot be converted to a {@code Path} |
64 * if the path string cannot be converted to a {@code Path} |
55 * |
65 * |
56 * @see FileSystem#getPath |
66 * @see FileSystem#getPath |
57 */ |
67 */ |
58 public static Path get(String path) { |
68 public static Path get(String path) { |
59 return FileSystems.getDefault().getPath(path); |
69 return FileSystems.getDefault().getPath(path); |
86 * Path} are all created in (possibly different invocations of) the same |
96 * Path} are all created in (possibly different invocations of) the same |
87 * Java virtual machine. Whether other providers make any guarantees is |
97 * Java virtual machine. Whether other providers make any guarantees is |
88 * provider specific and therefore unspecified. |
98 * provider specific and therefore unspecified. |
89 * |
99 * |
90 * @param uri |
100 * @param uri |
91 * The URI to convert |
101 * the URI to convert |
92 * |
102 * |
93 * @return The resulting {@code Path} |
103 * @return the resulting {@code Path} |
94 * |
104 * |
95 * @throws IllegalArgumentException |
105 * @throws IllegalArgumentException |
96 * If preconditions on the {@code uri} parameter do not hold. The |
106 * if preconditions on the {@code uri} parameter do not hold. The |
97 * format of the URI is provider specific. |
107 * format of the URI is provider specific. |
98 * @throws FileSystemNotFoundException |
108 * @throws FileSystemNotFoundException |
99 * If the file system identified by the URI does not exist or the |
109 * if the file system identified by the URI does not exist or the |
100 * provider identified by the URI's scheme component is not installed |
110 * provider identified by the URI's scheme component is not installed |
101 * @throws SecurityException |
111 * @throws SecurityException |
102 * If a security manager is installed and it denies an unspecified |
112 * if a security manager is installed and it denies an unspecified |
103 * permission to access the file system |
113 * permission to access the file system |
104 */ |
114 */ |
105 public static Path get(URI uri) { |
115 public static Path get(URI uri) { |
106 String scheme = uri.getScheme(); |
116 String scheme = uri.getScheme(); |
107 if (scheme == null) |
117 if (scheme == null) |