src/java.base/share/classes/java/nio/file/Path.java
author bpb
Thu, 22 Mar 2018 12:30:47 -0700
changeset 49285 4d2e3f5abb48
parent 47216 71c04702a3d5
permissions -rw-r--r--
8194746: (fs) Add equivalents of Paths.get to Path interface Summary: Copy Paths.get() methods to Path.get() methods and have former call latter Reviewed-by: alanb, forax, chegar, psandoz
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
     1
/*
49285
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
     2
 * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
     4
 *
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4059
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4059
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    10
 *
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    15
 * accompanied this code).
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    16
 *
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4059
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4059
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4059
diff changeset
    23
 * questions.
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    24
 */
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    25
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    26
package java.nio.file;
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    27
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
    28
import java.io.File;
3065
452aaa2899fc 6838333: New I/O: Update file system API to jsr203/nio2-b101
alanb
parents: 2589
diff changeset
    29
import java.io.IOException;
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    30
import java.net.URI;
49285
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
    31
import java.nio.file.spi.FileSystemProvider;
3065
452aaa2899fc 6838333: New I/O: Update file system API to jsr203/nio2-b101
alanb
parents: 2589
diff changeset
    32
import java.util.Iterator;
28244
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
    33
import java.util.NoSuchElementException;
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    34
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    35
/**
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
    36
 * An object that may be used to locate a file in a file system. It will
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
    37
 * typically represent a system dependent file path.
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    38
 *
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
    39
 * <p> A {@code Path} represents a path that is hierarchical and composed of a
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
    40
 * sequence of directory and file name elements separated by a special separator
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
    41
 * or delimiter. A <em>root component</em>, that identifies a file system
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
    42
 * hierarchy, may also be present. The name element that is <em>farthest</em>
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
    43
 * from the root of the directory hierarchy is the name of a file or directory.
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
    44
 * The other name elements are directory names. A {@code Path} can represent a
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
    45
 * root, a root and a sequence of names, or simply one or more name elements.
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
    46
 * A {@code Path} is considered to be an <i>empty path</i> if it consists
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
    47
 * solely of one name element that is empty. Accessing a file using an
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
    48
 * <i>empty path</i> is equivalent to accessing the default directory of the
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
    49
 * file system. {@code Path} defines the {@link #getFileName() getFileName},
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
    50
 * {@link #getParent getParent}, {@link #getRoot getRoot}, and {@link #subpath
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
    51
 * subpath} methods to access the path components or a subsequence of its name
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
    52
 * elements.
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    53
 *
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    54
 * <p> In addition to accessing the components of a path, a {@code Path} also
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
    55
 * defines the {@link #resolve(Path) resolve} and {@link #resolveSibling(Path)
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
    56
 * resolveSibling} methods to combine paths. The {@link #relativize relativize}
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
    57
 * method that can be used to construct a relative path between two paths.
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
    58
 * Paths can be {@link #compareTo compared}, and tested against each other using
12537
e206796f8175 7162262: (fs) Typo in java.nio.file.Path class description
psandoz
parents: 11519
diff changeset
    59
 * the {@link #startsWith startsWith} and {@link #endsWith endsWith} methods.
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    60
 *
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
    61
 * <p> This interface extends {@link Watchable} interface so that a directory
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
    62
 * located by a path can be {@link #register registered} with a {@link
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
    63
 * WatchService} and entries in the directory watched. </p>
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    64
 *
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
    65
 * <p> <b>WARNING:</b> This interface is only intended to be implemented by
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
    66
 * those developing custom file system implementations. Methods may be added to
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
    67
 * this interface in future releases. </p>
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    68
 *
18574
4aeaeb541678 8019380: doclint warnings in java.nio, java.nio.file.**, java.nio.channels.**
alanb
parents: 18156
diff changeset
    69
 * <h2>Accessing Files</h2>
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
    70
 * <p> Paths may be used with the {@link Files} class to operate on files,
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
    71
 * directories, and other types of files. For example, suppose we want a {@link
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
    72
 * java.io.BufferedReader} to read text from a file "{@code access.log}". The
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
    73
 * file is located in a directory "{@code logs}" relative to the current working
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
    74
 * directory and is UTF-8 encoded.
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    75
 * <pre>
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
    76
 *     Path path = FileSystems.getDefault().getPath("logs", "access.log");
11519
4cc0b4da6c36 7068856: (fs) Typo in Files.isSameFile() javadoc
alanb
parents: 9789
diff changeset
    77
 *     BufferedReader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8);
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    78
 * </pre>
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    79
 *
44844
b2b4d98404ba 8179364: update "<a name=" in java.base module to use id attribute
jjg
parents: 35703
diff changeset
    80
 * <a id="interop"></a><h2>Interoperability</h2>
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
    81
 * <p> Paths associated with the default {@link
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    82
 * java.nio.file.spi.FileSystemProvider provider} are generally interoperable
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    83
 * with the {@link java.io.File java.io.File} class. Paths created by other
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    84
 * providers are unlikely to be interoperable with the abstract path names
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
    85
 * represented by {@code java.io.File}. The {@link java.io.File#toPath toPath}
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
    86
 * method may be used to obtain a {@code Path} from the abstract path name
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
    87
 * represented by a {@code java.io.File} object. The resulting {@code Path} can
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
    88
 * be used to operate on the same file as the {@code java.io.File} object. In
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
    89
 * addition, the {@link #toFile toFile} method is useful to construct a {@code
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
    90
 * File} from the {@code String} representation of a {@code Path}.
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    91
 *
18574
4aeaeb541678 8019380: doclint warnings in java.nio, java.nio.file.**, java.nio.channels.**
alanb
parents: 18156
diff changeset
    92
 * <h2>Concurrency</h2>
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
    93
 * <p> Implementations of this interface are immutable and safe for use by
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
    94
 * multiple concurrent threads.
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    95
 *
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    96
 * @since 1.7
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    97
 */
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
    98
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
    99
public interface Path
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   100
    extends Comparable<Path>, Iterable<Path>, Watchable
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   101
{
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   102
    /**
49285
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   103
     * Returns a {@code Path} by converting a path string, or a sequence of
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   104
     * strings that when joined form a path string. If {@code more} does not
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   105
     * specify any elements then the value of the {@code first} parameter is
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   106
     * the path string to convert. If {@code more} specifies one or more
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   107
     * elements then each non-empty string, including {@code first}, is
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   108
     * considered to be a sequence of name elements and is joined to form a
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   109
     * path string. The details as to how the Strings are joined is provider
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   110
     * specific but typically they will be joined using the
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   111
     * {@link FileSystem#getSeparator name-separator} as the separator.
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   112
     * For example, if the name separator is "{@code /}" and
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   113
     * {@code getPath("/foo","bar","gus")} is invoked, then the path string
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   114
     * {@code "/foo/bar/gus"} is converted to a {@code Path}. A {@code Path}
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   115
     * representing an empty path is returned if {@code first} is the empty
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   116
     * string and {@code more} does not contain any non-empty strings.
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   117
     *
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   118
     * <p> The {@code Path} is obtained by invoking the {@link FileSystem#getPath
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   119
     * getPath} method of the {@link FileSystems#getDefault default} {@link
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   120
     * FileSystem}.
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   121
     *
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   122
     * <p> Note that while this method is very convenient, using it will imply
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   123
     * an assumed reference to the default {@code FileSystem} and limit the
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   124
     * utility of the calling code. Hence it should not be used in library code
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   125
     * intended for flexible reuse. A more flexible alternative is to use an
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   126
     * existing {@code Path} instance as an anchor, such as:
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   127
     * <pre>{@code
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   128
     *     Path dir = ...
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   129
     *     Path path = dir.resolve("file");
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   130
     * }</pre>
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   131
     *
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   132
     * @param   first
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   133
     *          the path string or initial part of the path string
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   134
     * @param   more
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   135
     *          additional strings to be joined to form the path string
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   136
     *
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   137
     * @return  the resulting {@code Path}
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   138
     *
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   139
     * @throws  InvalidPathException
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   140
     *          if the path string cannot be converted to a {@code Path}
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   141
     *
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   142
     * @see FileSystem#getPath
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   143
     *
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   144
     * @since 11
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   145
     */
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   146
    public static Path of(String first, String... more) {
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   147
        return FileSystems.getDefault().getPath(first, more);
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   148
    }
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   149
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   150
    /**
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   151
     * Returns a {@code Path} by converting a URI.
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   152
     *
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   153
     * <p> This method iterates over the {@link FileSystemProvider#installedProviders()
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   154
     * installed} providers to locate the provider that is identified by the
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   155
     * URI {@link URI#getScheme scheme} of the given URI. URI schemes are
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   156
     * compared without regard to case. If the provider is found then its {@link
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   157
     * FileSystemProvider#getPath getPath} method is invoked to convert the
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   158
     * URI.
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   159
     *
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   160
     * <p> In the case of the default provider, identified by the URI scheme
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   161
     * "file", the given URI has a non-empty path component, and undefined query
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   162
     * and fragment components. Whether the authority component may be present
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   163
     * is platform specific. The returned {@code Path} is associated with the
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   164
     * {@link FileSystems#getDefault default} file system.
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   165
     *
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   166
     * <p> The default provider provides a similar <em>round-trip</em> guarantee
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   167
     * to the {@link java.io.File} class. For a given {@code Path} <i>p</i> it
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   168
     * is guaranteed that
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   169
     * <blockquote>{@code
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   170
     * Path.of(}<i>p</i>{@code .}{@link Path#toUri() toUri}{@code ()).equals(}
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   171
     * <i>p</i>{@code .}{@link Path#toAbsolutePath() toAbsolutePath}{@code ())}
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   172
     * </blockquote>
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   173
     * so long as the original {@code Path}, the {@code URI}, and the new {@code
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   174
     * Path} are all created in (possibly different invocations of) the same
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   175
     * Java virtual machine. Whether other providers make any guarantees is
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   176
     * provider specific and therefore unspecified.
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   177
     *
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   178
     * @param   uri
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   179
     *          the URI to convert
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   180
     *
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   181
     * @return  the resulting {@code Path}
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   182
     *
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   183
     * @throws  IllegalArgumentException
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   184
     *          if preconditions on the {@code uri} parameter do not hold. The
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   185
     *          format of the URI is provider specific.
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   186
     * @throws  FileSystemNotFoundException
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   187
     *          The file system, identified by the URI, does not exist and
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   188
     *          cannot be created automatically, or the provider identified by
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   189
     *          the URI's scheme component is not installed
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   190
     * @throws  SecurityException
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   191
     *          if a security manager is installed and it denies an unspecified
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   192
     *          permission to access the file system
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   193
     *
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   194
     * @since 11
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   195
     */
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   196
    public static Path of(URI uri) {
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   197
        String scheme =  uri.getScheme();
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   198
        if (scheme == null)
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   199
            throw new IllegalArgumentException("Missing scheme");
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   200
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   201
        // check for default provider to avoid loading of installed providers
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   202
        if (scheme.equalsIgnoreCase("file"))
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   203
            return FileSystems.getDefault().provider().getPath(uri);
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   204
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   205
        // try to find provider
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   206
        for (FileSystemProvider provider: FileSystemProvider.installedProviders()) {
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   207
            if (provider.getScheme().equalsIgnoreCase(scheme)) {
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   208
                return provider.getPath(uri);
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   209
            }
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   210
        }
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   211
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   212
        throw new FileSystemNotFoundException("Provider \"" + scheme + "\" not installed");
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   213
    }
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   214
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   215
    /**
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   216
     * Returns the file system that created this object.
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   217
     *
2072
80dfe4469bbd 6809132: (file) Javadoc style and consistency issues
alanb
parents: 2057
diff changeset
   218
     * @return  the file system that created this object
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   219
     */
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   220
    FileSystem getFileSystem();
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   221
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   222
    /**
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   223
     * Tells whether or not this path is absolute.
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   224
     *
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   225
     * <p> An absolute path is complete in that it doesn't need to be combined
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   226
     * with other path information in order to locate a file.
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   227
     *
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   228
     * @return  {@code true} if, and only if, this path is absolute
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   229
     */
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   230
    boolean isAbsolute();
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   231
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   232
    /**
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   233
     * Returns the root component of this path as a {@code Path} object,
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   234
     * or {@code null} if this path does not have a root component.
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   235
     *
2072
80dfe4469bbd 6809132: (file) Javadoc style and consistency issues
alanb
parents: 2057
diff changeset
   236
     * @return  a path representing the root component of this path,
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   237
     *          or {@code null}
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   238
     */
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   239
    Path getRoot();
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   240
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   241
    /**
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   242
     * Returns the name of the file or directory denoted by this path as a
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   243
     * {@code Path} object. The file name is the <em>farthest</em> element from
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   244
     * the root in the directory hierarchy.
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   245
     *
2072
80dfe4469bbd 6809132: (file) Javadoc style and consistency issues
alanb
parents: 2057
diff changeset
   246
     * @return  a path representing the name of the file or directory, or
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   247
     *          {@code null} if this path has zero elements
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   248
     */
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   249
    Path getFileName();
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   250
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   251
    /**
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   252
     * Returns the <em>parent path</em>, or {@code null} if this path does not
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   253
     * have a parent.
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   254
     *
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   255
     * <p> The parent of this path object consists of this path's root
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   256
     * component, if any, and each element in the path except for the
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   257
     * <em>farthest</em> from the root in the directory hierarchy. This method
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   258
     * does not access the file system; the path or its parent may not exist.
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   259
     * Furthermore, this method does not eliminate special names such as "."
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   260
     * and ".." that may be used in some implementations. On UNIX for example,
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   261
     * the parent of "{@code /a/b/c}" is "{@code /a/b}", and the parent of
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   262
     * {@code "x/y/.}" is "{@code x/y}". This method may be used with the {@link
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   263
     * #normalize normalize} method, to eliminate redundant names, for cases where
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   264
     * <em>shell-like</em> navigation is required.
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   265
     *
35703
0bcc18fb1c5e 8148821: (fs) Path.getParent() javadoc error
bpb
parents: 32143
diff changeset
   266
     * <p> If this path has more than one element, and no root component, then
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   267
     * this method is equivalent to evaluating the expression:
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   268
     * <blockquote><pre>
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   269
     * subpath(0,&nbsp;getNameCount()-1);
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   270
     * </pre></blockquote>
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   271
     *
2072
80dfe4469bbd 6809132: (file) Javadoc style and consistency issues
alanb
parents: 2057
diff changeset
   272
     * @return  a path representing the path's parent
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   273
     */
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   274
    Path getParent();
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   275
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   276
    /**
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   277
     * Returns the number of name elements in the path.
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   278
     *
2072
80dfe4469bbd 6809132: (file) Javadoc style and consistency issues
alanb
parents: 2057
diff changeset
   279
     * @return  the number of elements in the path, or {@code 0} if this path
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   280
     *          only represents a root component
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   281
     */
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   282
    int getNameCount();
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   283
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   284
    /**
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   285
     * Returns a name element of this path as a {@code Path} object.
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   286
     *
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   287
     * <p> The {@code index} parameter is the index of the name element to return.
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   288
     * The element that is <em>closest</em> to the root in the directory hierarchy
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   289
     * has index {@code 0}. The element that is <em>farthest</em> from the root
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   290
     * has index {@link #getNameCount count}{@code -1}.
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   291
     *
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   292
     * @param   index
2072
80dfe4469bbd 6809132: (file) Javadoc style and consistency issues
alanb
parents: 2057
diff changeset
   293
     *          the index of the element
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   294
     *
2072
80dfe4469bbd 6809132: (file) Javadoc style and consistency issues
alanb
parents: 2057
diff changeset
   295
     * @return  the name element
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   296
     *
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   297
     * @throws  IllegalArgumentException
2072
80dfe4469bbd 6809132: (file) Javadoc style and consistency issues
alanb
parents: 2057
diff changeset
   298
     *          if {@code index} is negative, {@code index} is greater than or
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   299
     *          equal to the number of elements, or this path has zero name
2072
80dfe4469bbd 6809132: (file) Javadoc style and consistency issues
alanb
parents: 2057
diff changeset
   300
     *          elements
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   301
     */
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   302
    Path getName(int index);
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   303
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   304
    /**
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   305
     * Returns a relative {@code Path} that is a subsequence of the name
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   306
     * elements of this path.
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   307
     *
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   308
     * <p> The {@code beginIndex} and {@code endIndex} parameters specify the
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   309
     * subsequence of name elements. The name that is <em>closest</em> to the root
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   310
     * in the directory hierarchy has index {@code 0}. The name that is
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   311
     * <em>farthest</em> from the root has index {@link #getNameCount
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   312
     * count}{@code -1}. The returned {@code Path} object has the name elements
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   313
     * that begin at {@code beginIndex} and extend to the element at index {@code
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   314
     * endIndex-1}.
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   315
     *
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   316
     * @param   beginIndex
2072
80dfe4469bbd 6809132: (file) Javadoc style and consistency issues
alanb
parents: 2057
diff changeset
   317
     *          the index of the first element, inclusive
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   318
     * @param   endIndex
2072
80dfe4469bbd 6809132: (file) Javadoc style and consistency issues
alanb
parents: 2057
diff changeset
   319
     *          the index of the last element, exclusive
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   320
     *
2072
80dfe4469bbd 6809132: (file) Javadoc style and consistency issues
alanb
parents: 2057
diff changeset
   321
     * @return  a new {@code Path} object that is a subsequence of the name
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   322
     *          elements in this {@code Path}
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   323
     *
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   324
     * @throws  IllegalArgumentException
2072
80dfe4469bbd 6809132: (file) Javadoc style and consistency issues
alanb
parents: 2057
diff changeset
   325
     *          if {@code beginIndex} is negative, or greater than or equal to
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   326
     *          the number of elements. If {@code endIndex} is less than or
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   327
     *          equal to {@code beginIndex}, or larger than the number of elements.
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   328
     */
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   329
    Path subpath(int beginIndex, int endIndex);
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   330
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   331
    /**
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   332
     * Tests if this path starts with the given path.
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   333
     *
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   334
     * <p> This path <em>starts</em> with the given path if this path's root
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   335
     * component <em>starts</em> with the root component of the given path,
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   336
     * and this path starts with the same name elements as the given path.
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   337
     * If the given path has more name elements than this path then {@code false}
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   338
     * is returned.
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   339
     *
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   340
     * <p> Whether or not the root component of this path starts with the root
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   341
     * component of the given path is file system specific. If this path does
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   342
     * not have a root component and the given path has a root component then
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   343
     * this path does not start with the given path.
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   344
     *
8808
fc799c458da8 7017446: (fs) Updates to file system API (3/2011)
alanb
parents: 8158
diff changeset
   345
     * <p> If the given path is associated with a different {@code FileSystem}
fc799c458da8 7017446: (fs) Updates to file system API (3/2011)
alanb
parents: 8158
diff changeset
   346
     * to this path then {@code false} is returned.
fc799c458da8 7017446: (fs) Updates to file system API (3/2011)
alanb
parents: 8158
diff changeset
   347
     *
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   348
     * @param   other
2072
80dfe4469bbd 6809132: (file) Javadoc style and consistency issues
alanb
parents: 2057
diff changeset
   349
     *          the given path
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   350
     *
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   351
     * @return  {@code true} if this path starts with the given path; otherwise
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   352
     *          {@code false}
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   353
     */
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   354
    boolean startsWith(Path other);
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   355
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   356
    /**
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   357
     * Tests if this path starts with a {@code Path}, constructed by converting
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   358
     * the given path string, in exactly the manner specified by the {@link
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   359
     * #startsWith(Path) startsWith(Path)} method. On UNIX for example, the path
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   360
     * "{@code foo/bar}" starts with "{@code foo}" and "{@code foo/bar}". It
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   361
     * does not start with "{@code f}" or "{@code fo}".
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   362
     *
28244
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   363
     * @implSpec
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   364
     * The default implementation is equivalent for this path to:
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   365
     * <pre>{@code
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   366
     *     startsWith(getFileSystem().getPath(other));
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   367
     * }</pre>
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   368
     *
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   369
     * @param   other
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   370
     *          the given path string
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   371
     *
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   372
     * @return  {@code true} if this path starts with the given path; otherwise
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   373
     *          {@code false}
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   374
     *
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   375
     * @throws  InvalidPathException
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   376
     *          If the path string cannot be converted to a Path.
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   377
     */
28244
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   378
    default boolean startsWith(String other) {
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   379
        return startsWith(getFileSystem().getPath(other));
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   380
    }
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   381
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   382
    /**
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   383
     * Tests if this path ends with the given path.
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   384
     *
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   385
     * <p> If the given path has <em>N</em> elements, and no root component,
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   386
     * and this path has <em>N</em> or more elements, then this path ends with
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   387
     * the given path if the last <em>N</em> elements of each path, starting at
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   388
     * the element farthest from the root, are equal.
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   389
     *
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   390
     * <p> If the given path has a root component then this path ends with the
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   391
     * given path if the root component of this path <em>ends with</em> the root
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   392
     * component of the given path, and the corresponding elements of both paths
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   393
     * are equal. Whether or not the root component of this path ends with the
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   394
     * root component of the given path is file system specific. If this path
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   395
     * does not have a root component and the given path has a root component
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   396
     * then this path does not end with the given path.
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   397
     *
8808
fc799c458da8 7017446: (fs) Updates to file system API (3/2011)
alanb
parents: 8158
diff changeset
   398
     * <p> If the given path is associated with a different {@code FileSystem}
fc799c458da8 7017446: (fs) Updates to file system API (3/2011)
alanb
parents: 8158
diff changeset
   399
     * to this path then {@code false} is returned.
fc799c458da8 7017446: (fs) Updates to file system API (3/2011)
alanb
parents: 8158
diff changeset
   400
     *
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   401
     * @param   other
2072
80dfe4469bbd 6809132: (file) Javadoc style and consistency issues
alanb
parents: 2057
diff changeset
   402
     *          the given path
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   403
     *
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   404
     * @return  {@code true} if this path ends with the given path; otherwise
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   405
     *          {@code false}
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   406
     */
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   407
    boolean endsWith(Path other);
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   408
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   409
    /**
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   410
     * Tests if this path ends with a {@code Path}, constructed by converting
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   411
     * the given path string, in exactly the manner specified by the {@link
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   412
     * #endsWith(Path) endsWith(Path)} method. On UNIX for example, the path
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   413
     * "{@code foo/bar}" ends with "{@code foo/bar}" and "{@code bar}". It does
8808
fc799c458da8 7017446: (fs) Updates to file system API (3/2011)
alanb
parents: 8158
diff changeset
   414
     * not end with "{@code r}" or "{@code /bar}". Note that trailing separators
fc799c458da8 7017446: (fs) Updates to file system API (3/2011)
alanb
parents: 8158
diff changeset
   415
     * are not taken into account, and so invoking this method on the {@code
fc799c458da8 7017446: (fs) Updates to file system API (3/2011)
alanb
parents: 8158
diff changeset
   416
     * Path}"{@code foo/bar}" with the {@code String} "{@code bar/}" returns
fc799c458da8 7017446: (fs) Updates to file system API (3/2011)
alanb
parents: 8158
diff changeset
   417
     * {@code true}.
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   418
     *
28244
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   419
     * @implSpec
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   420
     * The default implementation is equivalent for this path to:
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   421
     * <pre>{@code
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   422
     *     endsWith(getFileSystem().getPath(other));
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   423
     * }</pre>
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   424
     *
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   425
     * @param   other
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   426
     *          the given path string
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   427
     *
14322
f17cf2e58bb3 8001565: (fs) Typo Path.endsWith(String) javadoc
dxu
parents: 14014
diff changeset
   428
     * @return  {@code true} if this path ends with the given path; otherwise
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   429
     *          {@code false}
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   430
     *
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   431
     * @throws  InvalidPathException
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   432
     *          If the path string cannot be converted to a Path.
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   433
     */
28244
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   434
    default boolean endsWith(String other) {
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   435
        return endsWith(getFileSystem().getPath(other));
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   436
    }
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   437
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   438
    /**
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   439
     * Returns a path that is this path with redundant name elements eliminated.
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   440
     *
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   441
     * <p> The precise definition of this method is implementation dependent but
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   442
     * in general it derives from this path, a path that does not contain
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   443
     * <em>redundant</em> name elements. In many file systems, the "{@code .}"
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   444
     * and "{@code ..}" are special names used to indicate the current directory
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   445
     * and parent directory. In such file systems all occurrences of "{@code .}"
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   446
     * are considered redundant. If a "{@code ..}" is preceded by a
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   447
     * non-"{@code ..}" name then both names are considered redundant (the
20536
2e22d22c52ed 8025983: Typo in Javadoc of Files.isRegularFile()
alanb
parents: 18574
diff changeset
   448
     * process to identify such names is repeated until it is no longer
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   449
     * applicable).
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   450
     *
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   451
     * <p> This method does not access the file system; the path may not locate
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   452
     * a file that exists. Eliminating "{@code ..}" and a preceding name from a
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   453
     * path may result in the path that locates a different file than the original
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   454
     * path. This can arise when the preceding name is a symbolic link.
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   455
     *
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   456
     * @return  the resulting path or this path if it does not contain
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   457
     *          redundant name elements; an empty path is returned if this path
27777
54a6546547d0 8066196: (fs) Typo in Path::normalize, empty path only returned if path does not have a root component
alanb
parents: 25859
diff changeset
   458
     *          does not have a root component and all name elements are redundant
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   459
     *
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   460
     * @see #getParent
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   461
     * @see #toRealPath
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   462
     */
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   463
    Path normalize();
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   464
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   465
    // -- resolution and relativization --
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   466
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   467
    /**
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   468
     * Resolve the given path against this path.
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   469
     *
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   470
     * <p> If the {@code other} parameter is an {@link #isAbsolute() absolute}
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   471
     * path then this method trivially returns {@code other}. If {@code other}
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   472
     * is an <i>empty path</i> then this method trivially returns this path.
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   473
     * Otherwise this method considers this path to be a directory and resolves
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   474
     * the given path against this path. In the simplest case, the given path
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   475
     * does not have a {@link #getRoot root} component, in which case this method
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   476
     * <em>joins</em> the given path to this path and returns a resulting path
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   477
     * that {@link #endsWith ends} with the given path. Where the given path has
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   478
     * a root component then resolution is highly implementation dependent and
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   479
     * therefore unspecified.
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   480
     *
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   481
     * @param   other
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   482
     *          the path to resolve against this path
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   483
     *
2072
80dfe4469bbd 6809132: (file) Javadoc style and consistency issues
alanb
parents: 2057
diff changeset
   484
     * @return  the resulting path
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   485
     *
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   486
     * @see #relativize
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   487
     */
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   488
    Path resolve(Path other);
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   489
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   490
    /**
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   491
     * Converts a given path string to a {@code Path} and resolves it against
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   492
     * this {@code Path} in exactly the manner specified by the {@link
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   493
     * #resolve(Path) resolve} method. For example, suppose that the name
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   494
     * separator is "{@code /}" and a path represents "{@code foo/bar}", then
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   495
     * invoking this method with the path string "{@code gus}" will result in
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   496
     * the {@code Path} "{@code foo/bar/gus}".
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   497
     *
28244
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   498
     * @implSpec
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   499
     * The default implementation is equivalent for this path to:
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   500
     * <pre>{@code
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   501
     *     resolve(getFileSystem().getPath(other));
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   502
     * }</pre>
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   503
     *
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   504
     * @param   other
2072
80dfe4469bbd 6809132: (file) Javadoc style and consistency issues
alanb
parents: 2057
diff changeset
   505
     *          the path string to resolve against this path
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   506
     *
2072
80dfe4469bbd 6809132: (file) Javadoc style and consistency issues
alanb
parents: 2057
diff changeset
   507
     * @return  the resulting path
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   508
     *
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   509
     * @throws  InvalidPathException
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   510
     *          if the path string cannot be converted to a Path.
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   511
     *
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   512
     * @see FileSystem#getPath
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   513
     */
28244
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   514
    default Path resolve(String other) {
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   515
        return resolve(getFileSystem().getPath(other));
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   516
    }
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   517
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   518
    /**
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   519
     * Resolves the given path against this path's {@link #getParent parent}
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   520
     * path. This is useful where a file name needs to be <i>replaced</i> with
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   521
     * another file name. For example, suppose that the name separator is
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   522
     * "{@code /}" and a path represents "{@code dir1/dir2/foo}", then invoking
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   523
     * this method with the {@code Path} "{@code bar}" will result in the {@code
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   524
     * Path} "{@code dir1/dir2/bar}". If this path does not have a parent path,
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   525
     * or {@code other} is {@link #isAbsolute() absolute}, then this method
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   526
     * returns {@code other}. If {@code other} is an empty path then this method
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   527
     * returns this path's parent, or where this path doesn't have a parent, the
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   528
     * empty path.
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   529
     *
28244
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   530
     * @implSpec
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   531
     * The default implementation is equivalent for this path to:
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   532
     * <pre>{@code
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   533
     *     (getParent() == null) ? other : getParent().resolve(other);
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   534
     * }</pre>
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   535
     * unless {@code other == null}, in which case a
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   536
     * {@code NullPointerException} is thrown.
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   537
     *
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   538
     * @param   other
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   539
     *          the path to resolve against this path's parent
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   540
     *
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   541
     * @return  the resulting path
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   542
     *
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   543
     * @see #resolve(Path)
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   544
     */
28244
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   545
    default Path resolveSibling(Path other) {
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   546
        if (other == null)
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   547
            throw new NullPointerException();
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   548
        Path parent = getParent();
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   549
        return (parent == null) ? other : parent.resolve(other);
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   550
    }
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   551
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   552
    /**
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   553
     * Converts a given path string to a {@code Path} and resolves it against
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   554
     * this path's {@link #getParent parent} path in exactly the manner
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   555
     * specified by the {@link #resolveSibling(Path) resolveSibling} method.
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   556
     *
28244
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   557
     * @implSpec
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   558
     * The default implementation is equivalent for this path to:
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   559
     * <pre>{@code
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   560
     *     resolveSibling(getFileSystem().getPath(other));
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   561
     * }</pre>
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   562
     *
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   563
     * @param   other
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   564
     *          the path string to resolve against this path's parent
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   565
     *
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   566
     * @return  the resulting path
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   567
     *
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   568
     * @throws  InvalidPathException
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   569
     *          if the path string cannot be converted to a Path.
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   570
     *
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   571
     * @see FileSystem#getPath
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   572
     */
28244
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   573
    default Path resolveSibling(String other) {
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   574
        return resolveSibling(getFileSystem().getPath(other));
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   575
    }
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   576
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   577
    /**
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   578
     * Constructs a relative path between this path and a given path.
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   579
     *
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   580
     * <p> Relativization is the inverse of {@link #resolve(Path) resolution}.
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   581
     * This method attempts to construct a {@link #isAbsolute relative} path
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   582
     * that when {@link #resolve(Path) resolved} against this path, yields a
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   583
     * path that locates the same file as the given path. For example, on UNIX,
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   584
     * if this path is {@code "/a/b"} and the given path is {@code "/a/b/c/d"}
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   585
     * then the resulting relative path would be {@code "c/d"}. Where this
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   586
     * path and the given path do not have a {@link #getRoot root} component,
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   587
     * then a relative path can be constructed. A relative path cannot be
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   588
     * constructed if only one of the paths have a root component. Where both
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   589
     * paths have a root component then it is implementation dependent if a
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   590
     * relative path can be constructed. If this path and the given path are
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   591
     * {@link #equals equal} then an <i>empty path</i> is returned.
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   592
     *
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   593
     * <p> For any two {@link #normalize normalized} paths <i>p</i> and
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   594
     * <i>q</i>, where <i>q</i> does not have a root component,
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   595
     * <blockquote>
32143
394ab6a6658d 8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents: 29986
diff changeset
   596
     *   <i>p</i>{@code .relativize(}<i>p</i>
394ab6a6658d 8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents: 29986
diff changeset
   597
     *   {@code .resolve(}<i>q</i>{@code )).equals(}<i>q</i>{@code )}
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   598
     * </blockquote>
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   599
     *
3215
c0e689b106bf 6857287: (file) Clarifications for symbolic link related javadoc
martin
parents: 3065
diff changeset
   600
     * <p> When symbolic links are supported, then whether the resulting path,
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   601
     * when resolved against this path, yields a path that can be used to locate
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   602
     * the {@link Files#isSameFile same} file as {@code other} is implementation
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   603
     * dependent. For example, if this path is  {@code "/a/b"} and the given
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   604
     * path is {@code "/a/x"} then the resulting relative path may be {@code
3215
c0e689b106bf 6857287: (file) Clarifications for symbolic link related javadoc
martin
parents: 3065
diff changeset
   605
     * "../x"}. If {@code "b"} is a symbolic link then is implementation
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   606
     * dependent if {@code "a/b/../x"} would locate the same file as {@code "/a/x"}.
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   607
     *
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   608
     * @param   other
4059
e838ac118185 6884480: (file) Path.relativize has typo in parameter description
alanb
parents: 3419
diff changeset
   609
     *          the path to relativize against this path
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   610
     *
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   611
     * @return  the resulting relative path, or an empty path if both paths are
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   612
     *          equal
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   613
     *
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   614
     * @throws  IllegalArgumentException
2072
80dfe4469bbd 6809132: (file) Javadoc style and consistency issues
alanb
parents: 2057
diff changeset
   615
     *          if {@code other} is not a {@code Path} that can be relativized
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   616
     *          against this path
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   617
     */
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   618
    Path relativize(Path other);
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   619
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   620
    /**
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   621
     * Returns a URI to represent this path.
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   622
     *
9789
49d6dba0d66b 7050358: (fs spec) Path.toUri doesn't allow custom providers to use opaque URIs
alanb
parents: 9679
diff changeset
   623
     * <p> This method constructs an absolute {@link URI} with a {@link
49d6dba0d66b 7050358: (fs spec) Path.toUri doesn't allow custom providers to use opaque URIs
alanb
parents: 9679
diff changeset
   624
     * URI#getScheme() scheme} equal to the URI scheme that identifies the
49d6dba0d66b 7050358: (fs spec) Path.toUri doesn't allow custom providers to use opaque URIs
alanb
parents: 9679
diff changeset
   625
     * provider. The exact form of the scheme specific part is highly provider
49d6dba0d66b 7050358: (fs spec) Path.toUri doesn't allow custom providers to use opaque URIs
alanb
parents: 9679
diff changeset
   626
     * dependent.
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   627
     *
9789
49d6dba0d66b 7050358: (fs spec) Path.toUri doesn't allow custom providers to use opaque URIs
alanb
parents: 9679
diff changeset
   628
     * <p> In the case of the default provider, the URI is hierarchical with
49d6dba0d66b 7050358: (fs spec) Path.toUri doesn't allow custom providers to use opaque URIs
alanb
parents: 9679
diff changeset
   629
     * a {@link URI#getPath() path} component that is absolute. The query and
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   630
     * fragment components are undefined. Whether the authority component is
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   631
     * defined or not is implementation dependent. There is no guarantee that
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   632
     * the {@code URI} may be used to construct a {@link java.io.File java.io.File}.
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   633
     * In particular, if this path represents a Universal Naming Convention (UNC)
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   634
     * path, then the UNC server name may be encoded in the authority component
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   635
     * of the resulting URI. In the case of the default provider, and the file
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   636
     * exists, and it can be determined that the file is a directory, then the
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   637
     * resulting {@code URI} will end with a slash.
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   638
     *
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   639
     * <p> The default provider provides a similar <em>round-trip</em> guarantee
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   640
     * to the {@link java.io.File} class. For a given {@code Path} <i>p</i> it
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   641
     * is guaranteed that
32143
394ab6a6658d 8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents: 29986
diff changeset
   642
     * <blockquote>
49285
4d2e3f5abb48 8194746: (fs) Add equivalents of Paths.get to Path interface
bpb
parents: 47216
diff changeset
   643
     * {@link Path#of(URI) Path.of}{@code (}<i>p</i>{@code .toUri()).equals(}<i>p</i>
32143
394ab6a6658d 8133459: replace <tt> tags (obsolete in html5) in java.nio docs
avstepan
parents: 29986
diff changeset
   644
     * {@code .}{@link #toAbsolutePath() toAbsolutePath}{@code ())}
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   645
     * </blockquote>
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   646
     * so long as the original {@code Path}, the {@code URI}, and the new {@code
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   647
     * Path} are all created in (possibly different invocations of) the same
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   648
     * Java virtual machine. Whether other providers make any guarantees is
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   649
     * provider specific and therefore unspecified.
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   650
     *
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   651
     * <p> When a file system is constructed to access the contents of a file
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   652
     * as a file system then it is highly implementation specific if the returned
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   653
     * URI represents the given path in the file system or it represents a
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   654
     * <em>compound</em> URI that encodes the URI of the enclosing file system.
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   655
     * A format for compound URIs is not defined in this release; such a scheme
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   656
     * may be added in a future release.
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   657
     *
9789
49d6dba0d66b 7050358: (fs spec) Path.toUri doesn't allow custom providers to use opaque URIs
alanb
parents: 9679
diff changeset
   658
     * @return  the URI representing this path
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   659
     *
3065
452aaa2899fc 6838333: New I/O: Update file system API to jsr203/nio2-b101
alanb
parents: 2589
diff changeset
   660
     * @throws  java.io.IOError
2072
80dfe4469bbd 6809132: (file) Javadoc style and consistency issues
alanb
parents: 2057
diff changeset
   661
     *          if an I/O error occurs obtaining the absolute path, or where a
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   662
     *          file system is constructed to access the contents of a file as
2072
80dfe4469bbd 6809132: (file) Javadoc style and consistency issues
alanb
parents: 2057
diff changeset
   663
     *          a file system, and the URI of the enclosing file system cannot be
80dfe4469bbd 6809132: (file) Javadoc style and consistency issues
alanb
parents: 2057
diff changeset
   664
     *          obtained
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   665
     *
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   666
     * @throws  SecurityException
2589
af4853bc7e87 6827153: Miscellaneous typos in javadoc
martin
parents: 2072
diff changeset
   667
     *          In the case of the default provider, and a security manager
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   668
     *          is installed, the {@link #toAbsolutePath toAbsolutePath} method
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   669
     *          throws a security exception.
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   670
     */
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   671
    URI toUri();
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   672
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   673
    /**
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   674
     * Returns a {@code Path} object representing the absolute path of this
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   675
     * path.
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   676
     *
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   677
     * <p> If this path is already {@link Path#isAbsolute absolute} then this
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   678
     * method simply returns this path. Otherwise, this method resolves the path
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   679
     * in an implementation dependent manner, typically by resolving the path
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   680
     * against a file system default directory. Depending on the implementation,
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   681
     * this method may throw an I/O error if the file system is not accessible.
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   682
     *
2072
80dfe4469bbd 6809132: (file) Javadoc style and consistency issues
alanb
parents: 2057
diff changeset
   683
     * @return  a {@code Path} object representing the absolute path
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   684
     *
14014
da3648e13e67 8000269: Cleanup javadoc warnings
alanb
parents: 12537
diff changeset
   685
     * @throws  java.io.IOError
2072
80dfe4469bbd 6809132: (file) Javadoc style and consistency issues
alanb
parents: 2057
diff changeset
   686
     *          if an I/O error occurs
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   687
     * @throws  SecurityException
3065
452aaa2899fc 6838333: New I/O: Update file system API to jsr203/nio2-b101
alanb
parents: 2589
diff changeset
   688
     *          In the case of the default provider, a security manager
452aaa2899fc 6838333: New I/O: Update file system API to jsr203/nio2-b101
alanb
parents: 2589
diff changeset
   689
     *          is installed, and this path is not absolute, then the security
452aaa2899fc 6838333: New I/O: Update file system API to jsr203/nio2-b101
alanb
parents: 2589
diff changeset
   690
     *          manager's {@link SecurityManager#checkPropertyAccess(String)
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   691
     *          checkPropertyAccess} method is invoked to check access to the
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   692
     *          system property {@code user.dir}
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   693
     */
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   694
    Path toAbsolutePath();
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   695
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   696
    /**
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   697
     * Returns the <em>real</em> path of an existing file.
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   698
     *
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   699
     * <p> The precise definition of this method is implementation dependent but
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   700
     * in general it derives from this path, an {@link #isAbsolute absolute}
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   701
     * path that locates the {@link Files#isSameFile same} file as this path, but
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   702
     * with name elements that represent the actual name of the directories
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   703
     * and the file. For example, where filename comparisons on a file system
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   704
     * are case insensitive then the name elements represent the names in their
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   705
     * actual case. Additionally, the resulting path has redundant name
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   706
     * elements removed.
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   707
     *
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   708
     * <p> If this path is relative then its absolute path is first obtained,
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   709
     * as if by invoking the {@link #toAbsolutePath toAbsolutePath} method.
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   710
     *
9025
a72fc1fc4b71 7029979: (fs) Path.toRealPath(boolean) should be toRealPath(LinkOption...)
alanb
parents: 8808
diff changeset
   711
     * <p> The {@code options} array may be used to indicate how symbolic links
a72fc1fc4b71 7029979: (fs) Path.toRealPath(boolean) should be toRealPath(LinkOption...)
alanb
parents: 8808
diff changeset
   712
     * are handled. By default, symbolic links are resolved to their final
a72fc1fc4b71 7029979: (fs) Path.toRealPath(boolean) should be toRealPath(LinkOption...)
alanb
parents: 8808
diff changeset
   713
     * target. If the option {@link LinkOption#NOFOLLOW_LINKS NOFOLLOW_LINKS} is
a72fc1fc4b71 7029979: (fs) Path.toRealPath(boolean) should be toRealPath(LinkOption...)
alanb
parents: 8808
diff changeset
   714
     * present then this method does not resolve symbolic links.
a72fc1fc4b71 7029979: (fs) Path.toRealPath(boolean) should be toRealPath(LinkOption...)
alanb
parents: 8808
diff changeset
   715
     *
a72fc1fc4b71 7029979: (fs) Path.toRealPath(boolean) should be toRealPath(LinkOption...)
alanb
parents: 8808
diff changeset
   716
     * Some implementations allow special names such as "{@code ..}" to refer to
a72fc1fc4b71 7029979: (fs) Path.toRealPath(boolean) should be toRealPath(LinkOption...)
alanb
parents: 8808
diff changeset
   717
     * the parent directory. When deriving the <em>real path</em>, and a
a72fc1fc4b71 7029979: (fs) Path.toRealPath(boolean) should be toRealPath(LinkOption...)
alanb
parents: 8808
diff changeset
   718
     * "{@code ..}" (or equivalent) is preceded by a non-"{@code ..}" name then
a72fc1fc4b71 7029979: (fs) Path.toRealPath(boolean) should be toRealPath(LinkOption...)
alanb
parents: 8808
diff changeset
   719
     * an implementation will typically cause both names to be removed. When
a72fc1fc4b71 7029979: (fs) Path.toRealPath(boolean) should be toRealPath(LinkOption...)
alanb
parents: 8808
diff changeset
   720
     * not resolving symbolic links and the preceding name is a symbolic link
a72fc1fc4b71 7029979: (fs) Path.toRealPath(boolean) should be toRealPath(LinkOption...)
alanb
parents: 8808
diff changeset
   721
     * then the names are only removed if it guaranteed that the resulting path
a72fc1fc4b71 7029979: (fs) Path.toRealPath(boolean) should be toRealPath(LinkOption...)
alanb
parents: 8808
diff changeset
   722
     * will locate the same file as this path.
a72fc1fc4b71 7029979: (fs) Path.toRealPath(boolean) should be toRealPath(LinkOption...)
alanb
parents: 8808
diff changeset
   723
     *
a72fc1fc4b71 7029979: (fs) Path.toRealPath(boolean) should be toRealPath(LinkOption...)
alanb
parents: 8808
diff changeset
   724
     * @param   options
a72fc1fc4b71 7029979: (fs) Path.toRealPath(boolean) should be toRealPath(LinkOption...)
alanb
parents: 8808
diff changeset
   725
     *          options indicating how symbolic links are handled
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   726
     *
2072
80dfe4469bbd 6809132: (file) Javadoc style and consistency issues
alanb
parents: 2057
diff changeset
   727
     * @return  an absolute path represent the <em>real</em> path of the file
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   728
     *          located by this object
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   729
     *
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   730
     * @throws  IOException
2072
80dfe4469bbd 6809132: (file) Javadoc style and consistency issues
alanb
parents: 2057
diff changeset
   731
     *          if the file does not exist or an I/O error occurs
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   732
     * @throws  SecurityException
2589
af4853bc7e87 6827153: Miscellaneous typos in javadoc
martin
parents: 2072
diff changeset
   733
     *          In the case of the default provider, and a security manager
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   734
     *          is installed, its {@link SecurityManager#checkRead(String) checkRead}
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   735
     *          method is invoked to check read access to the file, and where
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   736
     *          this path is not absolute, its {@link SecurityManager#checkPropertyAccess(String)
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   737
     *          checkPropertyAccess} method is invoked to check access to the
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   738
     *          system property {@code user.dir}
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   739
     */
9025
a72fc1fc4b71 7029979: (fs) Path.toRealPath(boolean) should be toRealPath(LinkOption...)
alanb
parents: 8808
diff changeset
   740
    Path toRealPath(LinkOption... options) throws IOException;
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   741
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   742
    /**
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   743
     * Returns a {@link File} object representing this path. Where this {@code
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   744
     * Path} is associated with the default provider, then this method is
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   745
     * equivalent to returning a {@code File} object constructed with the
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   746
     * {@code String} representation of this path.
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   747
     *
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   748
     * <p> If this path was created by invoking the {@code File} {@link
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   749
     * File#toPath toPath} method then there is no guarantee that the {@code
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   750
     * File} object returned by this method is {@link #equals equal} to the
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   751
     * original {@code File}.
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   752
     *
28244
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   753
     * @implSpec
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   754
     * The default implementation is equivalent for this path to:
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   755
     * <pre>{@code
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   756
     *     new File(toString());
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   757
     * }</pre>
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   758
     * if the {@code FileSystem} which created this {@code Path} is the default
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   759
     * file system; otherwise an {@code UnsupportedOperationException} is
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   760
     * thrown.
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   761
     *
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   762
     * @return  a {@code File} object representing this path
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   763
     *
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   764
     * @throws  UnsupportedOperationException
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   765
     *          if this {@code Path} is not associated with the default provider
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   766
     */
28244
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   767
    default File toFile() {
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   768
        if (getFileSystem() == FileSystems.getDefault()) {
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   769
            return new File(toString());
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   770
        } else {
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   771
            throw new UnsupportedOperationException("Path not associated with "
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   772
                    + "default file system.");
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   773
        }
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   774
    }
3065
452aaa2899fc 6838333: New I/O: Update file system API to jsr203/nio2-b101
alanb
parents: 2589
diff changeset
   775
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   776
    // -- watchable --
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   777
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   778
    /**
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   779
     * Registers the file located by this path with a watch service.
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   780
     *
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   781
     * <p> In this release, this path locates a directory that exists. The
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   782
     * directory is registered with the watch service so that entries in the
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   783
     * directory can be watched. The {@code events} parameter is the events to
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   784
     * register and may contain the following events:
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   785
     * <ul>
9679
d98ae8bc45fc 7042979: Rename StandardSocketOption and StandardWatchEventKind
alanb
parents: 9676
diff changeset
   786
     *   <li>{@link StandardWatchEventKinds#ENTRY_CREATE ENTRY_CREATE} -
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   787
     *       entry created or moved into the directory</li>
9679
d98ae8bc45fc 7042979: Rename StandardSocketOption and StandardWatchEventKind
alanb
parents: 9676
diff changeset
   788
     *   <li>{@link StandardWatchEventKinds#ENTRY_DELETE ENTRY_DELETE} -
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   789
     *        entry deleted or moved out of the directory</li>
9679
d98ae8bc45fc 7042979: Rename StandardSocketOption and StandardWatchEventKind
alanb
parents: 9676
diff changeset
   790
     *   <li>{@link StandardWatchEventKinds#ENTRY_MODIFY ENTRY_MODIFY} -
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   791
     *        entry in directory was modified</li>
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   792
     * </ul>
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   793
     *
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   794
     * <p> The {@link WatchEvent#context context} for these events is the
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   795
     * relative path between the directory located by this path, and the path
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   796
     * that locates the directory entry that is created, deleted, or modified.
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   797
     *
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   798
     * <p> The set of events may include additional implementation specific
9679
d98ae8bc45fc 7042979: Rename StandardSocketOption and StandardWatchEventKind
alanb
parents: 9676
diff changeset
   799
     * event that are not defined by the enum {@link StandardWatchEventKinds}
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   800
     *
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   801
     * <p> The {@code modifiers} parameter specifies <em>modifiers</em> that
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   802
     * qualify how the directory is registered. This release does not define any
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   803
     * <em>standard</em> modifiers. It may contain implementation specific
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   804
     * modifiers.
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   805
     *
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   806
     * <p> Where a file is registered with a watch service by means of a symbolic
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   807
     * link then it is implementation specific if the watch continues to depend
3215
c0e689b106bf 6857287: (file) Clarifications for symbolic link related javadoc
martin
parents: 3065
diff changeset
   808
     * on the existence of the symbolic link after it is registered.
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   809
     *
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   810
     * @param   watcher
2072
80dfe4469bbd 6809132: (file) Javadoc style and consistency issues
alanb
parents: 2057
diff changeset
   811
     *          the watch service to which this object is to be registered
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   812
     * @param   events
2072
80dfe4469bbd 6809132: (file) Javadoc style and consistency issues
alanb
parents: 2057
diff changeset
   813
     *          the events for which this object should be registered
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   814
     * @param   modifiers
2072
80dfe4469bbd 6809132: (file) Javadoc style and consistency issues
alanb
parents: 2057
diff changeset
   815
     *          the modifiers, if any, that modify how the object is registered
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   816
     *
2072
80dfe4469bbd 6809132: (file) Javadoc style and consistency issues
alanb
parents: 2057
diff changeset
   817
     * @return  a key representing the registration of this object with the
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   818
     *          given watch service
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   819
     *
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   820
     * @throws  UnsupportedOperationException
2072
80dfe4469bbd 6809132: (file) Javadoc style and consistency issues
alanb
parents: 2057
diff changeset
   821
     *          if unsupported events or modifiers are specified
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   822
     * @throws  IllegalArgumentException
2072
80dfe4469bbd 6809132: (file) Javadoc style and consistency issues
alanb
parents: 2057
diff changeset
   823
     *          if an invalid combination of events or modifiers is specified
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   824
     * @throws  ClosedWatchServiceException
2072
80dfe4469bbd 6809132: (file) Javadoc style and consistency issues
alanb
parents: 2057
diff changeset
   825
     *          if the watch service is closed
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   826
     * @throws  NotDirectoryException
2072
80dfe4469bbd 6809132: (file) Javadoc style and consistency issues
alanb
parents: 2057
diff changeset
   827
     *          if the file is registered to watch the entries in a directory
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   828
     *          and the file is not a directory  <i>(optional specific exception)</i>
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   829
     * @throws  IOException
2072
80dfe4469bbd 6809132: (file) Javadoc style and consistency issues
alanb
parents: 2057
diff changeset
   830
     *          if an I/O error occurs
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   831
     * @throws  SecurityException
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   832
     *          In the case of the default provider, and a security manager is
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   833
     *          installed, the {@link SecurityManager#checkRead(String) checkRead}
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   834
     *          method is invoked to check read access to the file.
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   835
     */
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   836
    @Override
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   837
    WatchKey register(WatchService watcher,
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   838
                      WatchEvent.Kind<?>[] events,
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   839
                      WatchEvent.Modifier... modifiers)
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   840
        throws IOException;
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   841
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   842
    /**
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   843
     * Registers the file located by this path with a watch service.
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   844
     *
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   845
     * <p> An invocation of this method behaves in exactly the same way as the
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   846
     * invocation
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   847
     * <pre>
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   848
     *     watchable.{@link #register(WatchService,WatchEvent.Kind[],WatchEvent.Modifier[]) register}(watcher, events, new WatchEvent.Modifier[0]);
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   849
     * </pre>
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   850
     *
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   851
     * <p> <b>Usage Example:</b>
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   852
     * Suppose we wish to register a directory for entry create, delete, and modify
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   853
     * events:
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   854
     * <pre>
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   855
     *     Path dir = ...
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   856
     *     WatchService watcher = ...
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   857
     *
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   858
     *     WatchKey key = dir.register(watcher, ENTRY_CREATE, ENTRY_DELETE, ENTRY_MODIFY);
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   859
     * </pre>
28244
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   860
     *
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   861
     * @implSpec
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   862
     * The default implementation is equivalent for this path to:
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   863
     * <pre>{@code
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   864
     *     register(watcher, events, new WatchEvent.Modifier[0]);
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   865
     * }</pre>
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   866
     *
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   867
     * @param   watcher
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   868
     *          The watch service to which this object is to be registered
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   869
     * @param   events
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   870
     *          The events for which this object should be registered
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   871
     *
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   872
     * @return  A key representing the registration of this object with the
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   873
     *          given watch service
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   874
     *
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   875
     * @throws  UnsupportedOperationException
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   876
     *          If unsupported events are specified
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   877
     * @throws  IllegalArgumentException
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   878
     *          If an invalid combination of events is specified
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   879
     * @throws  ClosedWatchServiceException
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   880
     *          If the watch service is closed
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   881
     * @throws  NotDirectoryException
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   882
     *          If the file is registered to watch the entries in a directory
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   883
     *          and the file is not a directory  <i>(optional specific exception)</i>
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   884
     * @throws  IOException
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   885
     *          If an I/O error occurs
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   886
     * @throws  SecurityException
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   887
     *          In the case of the default provider, and a security manager is
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   888
     *          installed, the {@link SecurityManager#checkRead(String) checkRead}
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   889
     *          method is invoked to check read access to the file.
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   890
     */
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   891
    @Override
28244
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   892
    default WatchKey register(WatchService watcher,
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   893
                      WatchEvent.Kind<?>... events) throws IOException {
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   894
        return register(watcher, events, new WatchEvent.Modifier[0]);
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   895
    }
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   896
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   897
    // -- Iterable --
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   898
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   899
    /**
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   900
     * Returns an iterator over the name elements of this path.
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   901
     *
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   902
     * <p> The first element returned by the iterator represents the name
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   903
     * element that is closest to the root in the directory hierarchy, the
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   904
     * second element is the next closest, and so on. The last element returned
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   905
     * is the name of the file or directory denoted by this path. The {@link
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   906
     * #getRoot root} component, if present, is not returned by the iterator.
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   907
     *
28244
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   908
     * @implSpec
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   909
     * The default implementation returns an {@code Iterator<Path>} which, for
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   910
     * this path, traverses the {@code Path}s returned by
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   911
     * {@code getName(index)}, where {@code index} ranges from zero to
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   912
     * {@code getNameCount() - 1}, inclusive.
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   913
     *
2072
80dfe4469bbd 6809132: (file) Javadoc style and consistency issues
alanb
parents: 2057
diff changeset
   914
     * @return  an iterator over the name elements of this path.
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   915
     */
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   916
    @Override
28244
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   917
    default Iterator<Path> iterator() {
29986
97167d851fc4 8078467: Update core libraries to use diamond with anonymous classes
darcy
parents: 28244
diff changeset
   918
        return new Iterator<>() {
28244
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   919
            private int i = 0;
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   920
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   921
            @Override
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   922
            public boolean hasNext() {
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   923
                return (i < getNameCount());
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   924
            }
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   925
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   926
            @Override
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   927
            public Path next() {
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   928
                if (i < getNameCount()) {
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   929
                    Path result = getName(i);
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   930
                    i++;
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   931
                    return result;
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   932
                } else {
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   933
                    throw new NoSuchElementException();
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   934
                }
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   935
            }
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   936
        };
1b52033818b1 8030090: (fs) Add default methods to Path for derived methods
bpb
parents: 27777
diff changeset
   937
    }
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   938
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   939
    // -- compareTo/equals/hashCode --
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   940
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   941
    /**
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   942
     * Compares two abstract paths lexicographically. The ordering defined by
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   943
     * this method is provider specific, and in the case of the default
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   944
     * provider, platform specific. This method does not access the file system
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   945
     * and neither file is required to exist.
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   946
     *
8808
fc799c458da8 7017446: (fs) Updates to file system API (3/2011)
alanb
parents: 8158
diff changeset
   947
     * <p> This method may not be used to compare paths that are associated
fc799c458da8 7017446: (fs) Updates to file system API (3/2011)
alanb
parents: 8158
diff changeset
   948
     * with different file system providers.
fc799c458da8 7017446: (fs) Updates to file system API (3/2011)
alanb
parents: 8158
diff changeset
   949
     *
2072
80dfe4469bbd 6809132: (file) Javadoc style and consistency issues
alanb
parents: 2057
diff changeset
   950
     * @param   other  the path compared to this path.
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   951
     *
2072
80dfe4469bbd 6809132: (file) Javadoc style and consistency issues
alanb
parents: 2057
diff changeset
   952
     * @return  zero if the argument is {@link #equals equal} to this path, a
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   953
     *          value less than zero if this path is lexicographically less than
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   954
     *          the argument, or a value greater than zero if this path is
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   955
     *          lexicographically greater than the argument
8808
fc799c458da8 7017446: (fs) Updates to file system API (3/2011)
alanb
parents: 8158
diff changeset
   956
     *
fc799c458da8 7017446: (fs) Updates to file system API (3/2011)
alanb
parents: 8158
diff changeset
   957
     * @throws  ClassCastException
fc799c458da8 7017446: (fs) Updates to file system API (3/2011)
alanb
parents: 8158
diff changeset
   958
     *          if the paths are associated with different providers
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   959
     */
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   960
    @Override
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   961
    int compareTo(Path other);
3065
452aaa2899fc 6838333: New I/O: Update file system API to jsr203/nio2-b101
alanb
parents: 2589
diff changeset
   962
452aaa2899fc 6838333: New I/O: Update file system API to jsr203/nio2-b101
alanb
parents: 2589
diff changeset
   963
    /**
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   964
     * Tests this path for equality with the given object.
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   965
     *
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   966
     * <p> If the given object is not a Path, or is a Path associated with a
8808
fc799c458da8 7017446: (fs) Updates to file system API (3/2011)
alanb
parents: 8158
diff changeset
   967
     * different {@code FileSystem}, then this method returns {@code false}.
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   968
     *
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   969
     * <p> Whether or not two path are equal depends on the file system
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   970
     * implementation. In some cases the paths are compared without regard
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   971
     * to case, and others are case sensitive. This method does not access the
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   972
     * file system and the file is not required to exist. Where required, the
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   973
     * {@link Files#isSameFile isSameFile} method may be used to check if two
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   974
     * paths locate the same file.
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   975
     *
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   976
     * <p> This method satisfies the general contract of the {@link
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   977
     * java.lang.Object#equals(Object) Object.equals} method. </p>
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   978
     *
2072
80dfe4469bbd 6809132: (file) Javadoc style and consistency issues
alanb
parents: 2057
diff changeset
   979
     * @param   other
80dfe4469bbd 6809132: (file) Javadoc style and consistency issues
alanb
parents: 2057
diff changeset
   980
     *          the object to which this object is to be compared
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   981
     *
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   982
     * @return  {@code true} if, and only if, the given object is a {@code Path}
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   983
     *          that is identical to this {@code Path}
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   984
     */
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   985
    boolean equals(Object other);
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   986
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   987
    /**
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   988
     * Computes a hash code for this path.
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   989
     *
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   990
     * <p> The hash code is based upon the components of the path, and
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   991
     * satisfies the general contract of the {@link Object#hashCode
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   992
     * Object.hashCode} method.
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   993
     *
2072
80dfe4469bbd 6809132: (file) Javadoc style and consistency issues
alanb
parents: 2057
diff changeset
   994
     * @return  the hash-code value for this path
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   995
     */
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
   996
    int hashCode();
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   997
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   998
    /**
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
   999
     * Returns the string representation of this path.
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
  1000
     *
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
  1001
     * <p> If this path was created by converting a path string using the
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
  1002
     * {@link FileSystem#getPath getPath} method then the path string returned
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
  1003
     * by this method may differ from the original String used to create the path.
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
  1004
     *
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
  1005
     * <p> The returned path string uses the default name {@link
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
  1006
     * FileSystem#getSeparator separator} to separate names in the path.
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
  1007
     *
2072
80dfe4469bbd 6809132: (file) Javadoc style and consistency issues
alanb
parents: 2057
diff changeset
  1008
     * @return  the string representation of this path
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
  1009
     */
8158
77d9c0f1c19f 7006126: (fs) Updates to file system API (1/2011)
alanb
parents: 7668
diff changeset
  1010
    String toString();
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents:
diff changeset
  1011
}