1Z0-805 · Question #52
The default file system includes a logFiles directory that contains the following files: log_Jan2009 log_01_2010 log_Feb2010 log_Feb2011 log-sum-2012 How many files the matcher in this fragment…
The correct answer is A. One. The glob pattern is: any three characters, followed by _ ,followed by any number of characters, and ending with a 1. Only log_Feb2011 matches this pattern. You can use glob syntax to specify pattern-matching behavior. A glob pattern is specified as a string and is matched…
Question
The default file system includes a logFiles directory that contains the following files:
log_Jan2009 log_01_2010 log_Feb2010 log_Feb2011 log-sum-2012 How many files the matcher in this fragment match? PathMatcher matcher = FileSystems.getDefault ().getPathMatcher ("glob:???_*1");
Options
- AOne
- BTwo
- CThree
- DFour
- EFive
- FSix
How the community answered
(28 responses)- A86% (24)
- B4% (1)
- C4% (1)
- E7% (2)
Explanation
The glob pattern is: any three characters, followed by _ ,followed by any number of characters, and ending with a 1. Only log_Feb2011 matches this pattern. You can use glob syntax to specify pattern-matching behavior. A glob pattern is specified as a string and is matched against other strings, such as directory or file names. Glob syntax follows several simple rules: * An asterisk, *, matches any number of characters (including none). ** Two asterisks, , works like * but crosses directory boundaries. This syntax is generally used for matching complete * A question mark, ?, matches exactly one character. * Braces specify a collection of subpatterns. For example: {sun,moon,stars} matches "sun", "moon", or "stars." {temp,tmp} matches all strings beginning with "temp" or "tmp." * Square brackets convey a set of single characters or, when the hyphen character (-) is used, a range of characters. For example: [aeiou] matches any lowercase vowel. [0-9] matches any digit. [A-Z] matches any uppercase letter. [a-z,A-Z] matches any uppercase or lowercase letter. * Within the square brackets, *, ?, and \ match themselves. *All other characters match themselves. * To match *, ?, or the other special characters, you can escape them by using the backslash character, . For example: \ matches a single backslash, and ? matches the question mark.
Topics
Community Discussion
No community discussion yet for this question.