private void addDirectory(File directory) throws IOException { if (!directory.isDirectory()) { throw new IllegalStateException("Not a directory: " + directory); } File[] files = directory.listFiles(); if (files == null) { throw new IllegalStateException("No files found in " + directory); } for (File file : files) { if (file.isDirectory()) { addDirectory(file); } else if (file.getName().endsWith(".jar")) { try { addResource0(file.toURI().toURL()); } catch (IOException e) { throw new IllegalStateException(e); } } else { try { String relativeName = directory.toURI().relativize(file.toURI()).getPath(); FileInputStream fileInputStream = new FileInputStream(file); addClassIfClass(fileInputStream, relativeName); resources.put(relativeName, file.toURI().toURL()); fileInputStream.close(); } catch (MalformedURLException | FileNotFoundException e) { throw new IllegalStateException(e); } } } }
private void addDirectory(File directory) throws IOException { if (!directory.isDirectory()) { throw new IllegalStateException("Not a directory: " + directory); } File[] files = directory.listFiles(); if (files == null) { throw new IllegalStateException("No files found in " + directory); } for (File file : files) { if (file.isDirectory()) { addDirectory(file); } else if (file.getName().endsWith(".jar")) { try { addResource0(file.toURI().toURL()); } catch (IOException e) { throw new IllegalStateException(e); } } else { try { String relativeName = directory.toURI().relativize(file.toURI()).getPath(); FileInputStream fileInputStream = new FileInputStream(file); addClassIfClass(fileInputStream, relativeName); resources.put(relativeName, file.toURI().toURL()); fileInputStream.close(); } catch (MalformedURLException | FileNotFoundException e) { throw new IllegalStateException(e); } } } }
} else { try { addDirectory(new File(url.toURI())); } catch (URISyntaxException e) { throw new IllegalStateException(e);
} else { try { addDirectory(new File(url.toURI())); } catch (URISyntaxException e) { throw new IllegalStateException(e);