src/share/classes/java/nio/file/Path.java

Print this page


   1 /*
   2  * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 280      *          the given path
 281      *
 282      * @return  {@code true} if this path ends with the given path; otherwise
 283      *          {@code false}
 284      */
 285     boolean endsWith(Path other);
 286 
 287     /**
 288      * Tests if this path ends with a {@code Path}, constructed by converting
 289      * the given path string, in exactly the manner specified by the {@link
 290      * #endsWith(Path) endsWith(Path)} method. On UNIX for example, the path
 291      * "{@code foo/bar}" ends with "{@code foo/bar}" and "{@code bar}". It does
 292      * not end with "{@code r}" or "{@code /bar}". Note that trailing separators
 293      * are not taken into account, and so invoking this method on the {@code
 294      * Path}"{@code foo/bar}" with the {@code String} "{@code bar/}" returns
 295      * {@code true}.
 296      *
 297      * @param   other
 298      *          the given path string
 299      *
 300      * @return  {@code true} if this path starts with the given path; otherwise
 301      *          {@code false}
 302      *
 303      * @throws  InvalidPathException
 304      *          If the path string cannot be converted to a Path.
 305      */
 306     boolean endsWith(String other);
 307 
 308     /**
 309      * Returns a path that is this path with redundant name elements eliminated.
 310      *
 311      * <p> The precise definition of this method is implementation dependent but
 312      * in general it derives from this path, a path that does not contain
 313      * <em>redundant</em> name elements. In many file systems, the "{@code .}"
 314      * and "{@code ..}" are special names used to indicate the current directory
 315      * and parent directory. In such file systems all occurrences of "{@code .}"
 316      * are considered redundant. If a "{@code ..}" is preceded by a
 317      * non-"{@code ..}" name then both names are considered redundant (the
 318      * process to identify such names is repeated until is it no longer
 319      * applicable).
 320      *


   1 /*
   2  * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 280      *          the given path
 281      *
 282      * @return  {@code true} if this path ends with the given path; otherwise
 283      *          {@code false}
 284      */
 285     boolean endsWith(Path other);
 286 
 287     /**
 288      * Tests if this path ends with a {@code Path}, constructed by converting
 289      * the given path string, in exactly the manner specified by the {@link
 290      * #endsWith(Path) endsWith(Path)} method. On UNIX for example, the path
 291      * "{@code foo/bar}" ends with "{@code foo/bar}" and "{@code bar}". It does
 292      * not end with "{@code r}" or "{@code /bar}". Note that trailing separators
 293      * are not taken into account, and so invoking this method on the {@code
 294      * Path}"{@code foo/bar}" with the {@code String} "{@code bar/}" returns
 295      * {@code true}.
 296      *
 297      * @param   other
 298      *          the given path string
 299      *
 300      * @return  {@code true} if this path ends with the given path; otherwise
 301      *          {@code false}
 302      *
 303      * @throws  InvalidPathException
 304      *          If the path string cannot be converted to a Path.
 305      */
 306     boolean endsWith(String other);
 307 
 308     /**
 309      * Returns a path that is this path with redundant name elements eliminated.
 310      *
 311      * <p> The precise definition of this method is implementation dependent but
 312      * in general it derives from this path, a path that does not contain
 313      * <em>redundant</em> name elements. In many file systems, the "{@code .}"
 314      * and "{@code ..}" are special names used to indicate the current directory
 315      * and parent directory. In such file systems all occurrences of "{@code .}"
 316      * are considered redundant. If a "{@code ..}" is preceded by a
 317      * non-"{@code ..}" name then both names are considered redundant (the
 318      * process to identify such names is repeated until is it no longer
 319      * applicable).
 320      *