示例#1
0
  public boolean isDirectory() {
    try {
      URL url = getURL();

      if (!"file".equals(url.getProtocol())) {
        return false;
      }

      File file = new File(StringUtils.toURI(url.toString()).getSchemeSpecificPart());

      return file.isDirectory();
    } catch (Exception e) {
      return false;
    }
  }
示例#2
0
  public Collection<Resource> listResources() {
    try {
      URL url = getURL();

      if ("file".equals(url.getProtocol())) {
        File dir = new File(StringUtils.toURI(url.toString()).getSchemeSpecificPart());

        List<Resource> resources = new ArrayList<Resource>();

        for (File file : dir.listFiles()) {
          resources.add(new FileSystemResource(file));
        }

        return resources;
      }
    } catch (Exception e) {
      // swollow as we'll throw an exception anyway
    }

    throw new RuntimeException("This Resource cannot be listed, or is not a directory");
  }