示例#1
0
  @Test
  public void testFileResources2() throws Exception {
    String someResource = "/org/node/resource.txt";

    File file = new File("files/node-1.0-SNAPSHOT.jar");
    URL url1 = file.getAbsoluteFile().toURI().toURL();
    URL url2 = new File("files/invoke-1.0-SNAPSHOT.jar").getAbsoluteFile().toURI().toURL();

    URLClassLoader loader = new URLClassLoader(new URL[] {url1, url2});

    final List<String> resourcePaths = Classpaths.listFromClassLoader(loader, someResource);

    List<Path> list = IO.paths("classpath://org/node/");

    // List<Path> list = Classpaths.pathsFromClassLoader(loader, someResource);

    puts(multiply('-', 10), "Path ");
    for (Path path : list) {

      puts(path, path.getFileSystem(), path.getClass().getName());
      if (path.toString().endsWith(".txt")) {
        puts(IO.readPath(path));
      }
    }

    puts(multiply('-', 10), "String Path ");
    List<String> slist = IO.list("classpath://org/node/");

    for (String spath : slist) {

      puts(spath);
      if (spath.toString().endsWith(".txt")) {
        puts(IO.readResource(spath));
      }
    }
  }