@Override public List<URI> listFiles(URI directory) throws CatalogIOException { checkUriExists(directory); class ListFiles extends SimpleFileVisitor<Path> { private List<String> filePaths = new LinkedList<>(); @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { filePaths.add(file.toAbsolutePath().toString()); return super.visitFile(file, attrs); } public List<String> getFilePaths() { return filePaths; } } ListFiles fileVisitor = new ListFiles(); try { Files.walkFileTree(Paths.get(directory.getPath()), fileVisitor); } catch (IOException e) { throw new CatalogIOException("Unable to walkFileTree", e); } List<URI> fileUris = new LinkedList<>(); for (String filePath : fileVisitor.getFilePaths()) { try { fileUris.add(new URI("file", filePath, null)); } catch (URISyntaxException e) { throw CatalogIOException.uriSyntaxException(filePath, e); } } return fileUris; }