< prev index next >

src/java.base/share/classes/java/nio/file/FileSystem.java

Print this page




 298      * Returns a {@code PathMatcher} that performs match operations on the
 299      * {@code String} representation of {@link Path} objects by interpreting a
 300      * given pattern.
 301      *
 302      * The {@code syntaxAndPattern} parameter identifies the syntax and the
 303      * pattern and takes the form:
 304      * <blockquote><pre>
 305      * <i>syntax</i><b>:</b><i>pattern</i>
 306      * </pre></blockquote>
 307      * where {@code ':'} stands for itself.
 308      *
 309      * <p> A {@code FileSystem} implementation supports the "{@code glob}" and
 310      * "{@code regex}" syntaxes, and may support others. The value of the syntax
 311      * component is compared without regard to case.
 312      *
 313      * <p> When the syntax is "{@code glob}" then the {@code String}
 314      * representation of the path is matched using a limited pattern language
 315      * that resembles regular expressions but with a simpler syntax. For example:
 316      *
 317      * <blockquote>
 318      * <table border="0" summary="Pattern Language">


 319      * <tr>
 320      *   <td>{@code *.java}</td>
 321      *   <td>Matches a path that represents a file name ending in {@code .java}</td>
 322      * </tr>
 323      * <tr>
 324      *   <td>{@code *.*}</td>
 325      *   <td>Matches file names containing a dot</td>
 326      * </tr>
 327      * <tr>
 328      *   <td>{@code *.{java,class}}</td>
 329      *   <td>Matches file names ending with {@code .java} or {@code .class}</td>
 330      * </tr>
 331      * <tr>
 332      *   <td>{@code foo.?}</td>
 333      *   <td>Matches file names starting with {@code foo.} and a single
 334      *   character extension</td>
 335      * </tr>
 336      * <tr>
 337      *   <td><code>/home/*/*</code>
 338      *   <td>Matches <code>/home/gus/data</code> on UNIX platforms</td>
 339      * </tr>
 340      * <tr>
 341      *   <td><code>/home/**</code>
 342      *   <td>Matches <code>/home/gus</code> and
 343      *   <code>/home/gus/data</code> on UNIX platforms</td>
 344      * </tr>
 345      * <tr>
 346      *   <td><code>C:\\*</code>
 347      *   <td>Matches <code>C:\foo</code> and <code>C:\bar</code> on the Windows
 348      *   platform (note that the backslash is escaped; as a string literal in the
 349      *   Java Language the pattern would be <code>"C:\\\\*"</code>) </td>
 350      * </tr>
 351      *
 352      * </table>
 353      * </blockquote>
 354      *
 355      * <p> The following rules are used to interpret glob patterns:
 356      *
 357      * <ul>
 358      *   <li><p> The {@code *} character matches zero or more {@link Character
 359      *   characters} of a {@link Path#getName(int) name} component without
 360      *   crossing directory boundaries. </p></li>
 361      *
 362      *   <li><p> The {@code **} characters matches zero or more {@link Character
 363      *   characters} crossing directory boundaries. </p></li>
 364      *
 365      *   <li><p> The {@code ?} character matches exactly one character of a
 366      *   name component.</p></li>
 367      *
 368      *   <li><p> The backslash character ({@code \}) is used to escape characters
 369      *   that would otherwise be interpreted as special characters. The expression
 370      *   {@code \\} matches a single backslash and "\{" matches a left brace
 371      *   for example.  </p></li>




 298      * Returns a {@code PathMatcher} that performs match operations on the
 299      * {@code String} representation of {@link Path} objects by interpreting a
 300      * given pattern.
 301      *
 302      * The {@code syntaxAndPattern} parameter identifies the syntax and the
 303      * pattern and takes the form:
 304      * <blockquote><pre>
 305      * <i>syntax</i><b>:</b><i>pattern</i>
 306      * </pre></blockquote>
 307      * where {@code ':'} stands for itself.
 308      *
 309      * <p> A {@code FileSystem} implementation supports the "{@code glob}" and
 310      * "{@code regex}" syntaxes, and may support others. The value of the syntax
 311      * component is compared without regard to case.
 312      *
 313      * <p> When the syntax is "{@code glob}" then the {@code String}
 314      * representation of the path is matched using a limited pattern language
 315      * that resembles regular expressions but with a simpler syntax. For example:
 316      *
 317      * <blockquote>
 318      * <table>
 319      * <caption style="display:none">Pattern Language</caption>
 320      * <tbody>
 321      * <tr>
 322      *   <td>{@code *.java}</td>
 323      *   <td>Matches a path that represents a file name ending in {@code .java}</td>
 324      * </tr>
 325      * <tr>
 326      *   <td>{@code *.*}</td>
 327      *   <td>Matches file names containing a dot</td>
 328      * </tr>
 329      * <tr>
 330      *   <td>{@code *.{java,class}}</td>
 331      *   <td>Matches file names ending with {@code .java} or {@code .class}</td>
 332      * </tr>
 333      * <tr>
 334      *   <td>{@code foo.?}</td>
 335      *   <td>Matches file names starting with {@code foo.} and a single
 336      *   character extension</td>
 337      * </tr>
 338      * <tr>
 339      *   <td><code>/home/*/*</code>
 340      *   <td>Matches <code>/home/gus/data</code> on UNIX platforms</td>
 341      * </tr>
 342      * <tr>
 343      *   <td><code>/home/**</code>
 344      *   <td>Matches <code>/home/gus</code> and
 345      *   <code>/home/gus/data</code> on UNIX platforms</td>
 346      * </tr>
 347      * <tr>
 348      *   <td><code>C:\\*</code>
 349      *   <td>Matches <code>C:\foo</code> and <code>C:\bar</code> on the Windows
 350      *   platform (note that the backslash is escaped; as a string literal in the
 351      *   Java Language the pattern would be <code>"C:\\\\*"</code>) </td>
 352      * </tr>
 353      * </tbody>
 354      * </table>
 355      * </blockquote>
 356      *
 357      * <p> The following rules are used to interpret glob patterns:
 358      *
 359      * <ul>
 360      *   <li><p> The {@code *} character matches zero or more {@link Character
 361      *   characters} of a {@link Path#getName(int) name} component without
 362      *   crossing directory boundaries. </p></li>
 363      *
 364      *   <li><p> The {@code **} characters matches zero or more {@link Character
 365      *   characters} crossing directory boundaries. </p></li>
 366      *
 367      *   <li><p> The {@code ?} character matches exactly one character of a
 368      *   name component.</p></li>
 369      *
 370      *   <li><p> The backslash character ({@code \}) is used to escape characters
 371      *   that would otherwise be interpreted as special characters. The expression
 372      *   {@code \\} matches a single backslash and "\{" matches a left brace
 373      *   for example.  </p></li>


< prev index next >