Looks at this code:
URL url = FileReaderRandomBackgroundGenerator.class.getClassLoader().getResource(rootPath);
dir = new File(url.getFile());
If the path contains a space, hash mark (#), or any other character normally escaped by url-encoding, the result of url.getFile() will contain url-encoding escape sequences for those characters. For example, If the path is "/tmp/foo#/my projects/test", url.getFile() will return "/tmp/foo%23/my%20projects/test".
The fix is to url-decode the string before creating the File.