@@ -0,0 +1,1813 @@
+package glob;%0A%0Aimport java.io.File;%0Aimport java.nio.file.NotDirectoryException;%0Aimport java.util.ArrayList;%0Aimport java.util.regex.*;%0A%0A/**%0A *  Implements a glob-method which returns all the files in a directory matching the given pattern.%0A *%0A *  @author  Joel Abrahamsson%0A *  @version %25G%25%0A */%0Apublic class Glob%0A%7B%0A  /**%0A   *  Finds all files in a directory that matches the given regular expression.%0A   *%0A   *  @param directory the directory to search in%0A   *  @param regex     the regular expression to match against%0A   *  %0A   *  @return          an array containing the matching file names%0A   */%0A  public static String%5B%5D glob(File directory, Pattern regex) throws NotDirectoryException%0A  %7B%0A    if (!directory.isDirectory())%0A      throw new NotDirectoryException(directory.getName());%0A%0A    ArrayList%3CString%3E matches = new ArrayList%3CString%3E();%0A%0A    String%5B%5D fileNames = directory.list();%0A    for (String file : fileNames)%0A    %7B%0A      if (regex.matcher(file).find())%0A        matches.add(file);%0A    %7D%0A    %0A    return matches.toArray(new String%5Bmatches.size()%5D);%0A  %7D%0A%0A  public static void main(String%5B%5D args)%0A  %7B%0A    if (args.length %3E 1)%0A    %7B%0A      try%0A      %7B%0A        File directory = new File(args%5B0%5D);%0A        Pattern regex  = Pattern.compile(args%5B1%5D);%0A%0A        String%5B%5D matches = glob(directory, regex);%0A%0A        System.out.printf(%22Matched %25d files:%5Cn%22, matches.length);%0A        for (String match : matches)%0A          System.out.println(match);%0A      %7D%0A      catch (Exception e)%0A      %7B%0A        System.err.println(e);%0A        e.printStackTrace();%0A      %7D%0A    %7D%0A    else%0A    %7B%0A      System.out.println(%22Usage:%5Cn%22 +%0A                         %22java glob.Glob PATH REGEX%5Cn%22 +%0A                         %22%5CtPATH - Directory%5Cn%22 +%0A                         %22%5CtREGEX - The regular expression to match against%22);%0A    %7D%0A  %7D%0A%7D%0A

Implement glob-method