1

I'm using the following code to try to walk through all the .class files in the current classpath, however it is throwing a NoSuchFileException before iterating once. Am I doing something wrong?

Enumeration<URL> systemResources = ClassLoader.getSystemResources("");

        while (systemResources.hasMoreElements()) {
            String fileName = systemResources.nextElement().getPath();
            Stream<Path> filter = Files.walk(new File(fileName).toPath()).filter(Files::isRegularFile);
            Consumer<Path> renameMe = (path) ->
            {
                System.out.println(path.toString());
            };
            filter.forEach(renameMe);
        }
        ;
ThomYorkkke
  • 2,061
  • 3
  • 18
  • 26
  • You're looking for all the files named *empty string* in the classpath. Of course such a file does not exist. – RealSkeptic Nov 28 '14 at 23:34
  • It's my understanding that this is how I get the classpath. Am I wrong on this? – ThomYorkkke Nov 28 '14 at 23:37
  • No. There is nothing in the documentation nor the source code that indicates this should be so. Have a look at [this answer](http://stackoverflow.com/a/3923182/4125191) to a similar question. – RealSkeptic Nov 29 '14 at 00:04

0 Answers0