Question: Modify this chapters DirectoryDescription program to print name and size information for only those files whose glob pattern matches a user-specified string. To do this,

Modify this chapter’s DirectoryDescription program to print name and size information for only those files whose “glob” pattern matches a user-specified string. To do this, you’ll need to prompt for and read the desired “glob” pattern. In addition to Scanner, you’ll need to use the Java FileSystem and PathMatcher classes to create a matcher object like that in the constructor of this chapter’s FileVisitor class. Then, you’ll need to put the for-each loop’s printf statement inside an if statement whose condition is something like matcher.matches(name), where name comes from path.getFileName().

Step by Step Solution

3.42 Rating (165 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Sure here is how you might modify the DirectoryDescription program to only print name and size information for files that match a userspecified glob p... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Introduction To Programming With Java A Problem Solving Approach Questions!