private Collection<String> getResources(final String element, final Pattern pattern) { final ArrayList<String> resources = new ArrayList<>(); final File file = new File(element); if (isAJarFile(file)) { resources.addAll(getResourcesFromJarFile(file, pattern)); } else { resources.addAll(getResourcesFromDirectory(file, pattern)); } return removeUnnecessaryFilesFrom(resources); }
private Collection<String> getResourcesFromDirectory(final File directory, final Pattern pattern) { final ArrayList<String> retval = new ArrayList<>(); final File[] fileList = directory.listFiles(); if (fileList != null) { for (final File file : fileList) { if (file.isDirectory() && (file.exists())) { retval.addAll(getResourcesFromDirectory(file, pattern)); } else { String fileName = ""; if (file.exists()) { try { fileName = file.getCanonicalPath(); final boolean accept = pattern.matcher(fileName).matches(); if (accept) { retval.add(fileName); } } catch (final IOException e) { throw new ResourceCopyingError("Could not read from the JAR file " + fileName , e); } } } } } return retval; }
private Collection<String> getResources(final String element, final Pattern pattern) { final ArrayList<String> resources = new ArrayList<String>(); final File file = new File(element); if (isAJarFile(file)) { resources.addAll(getResourcesFromJarFile(file, pattern)); } else { resources.addAll(getResourcesFromDirectory(file, pattern)); } return removeUnnecessaryFilesFrom(resources); }
private Collection<String> getResources(final String element, final Pattern pattern) { final ArrayList<String> resources = new ArrayList<String>(); final File file = new File(element); if (isAJarFile(file)) { resources.addAll(getResourcesFromJarFile(file, pattern)); } else { resources.addAll(getResourcesFromDirectory(file, pattern)); } return removeUnnecessaryFilesFrom(resources); }
private Collection<String> getResourcesFromDirectory(final File directory, final Pattern pattern) { final ArrayList<String> retval = new ArrayList<String>(); final File[] fileList = directory.listFiles(); if (fileList != null) { for (final File file : fileList) { if (file.isDirectory() && (file.exists())) { retval.addAll(getResourcesFromDirectory(file, pattern)); } else { if (file.exists()) { try { final String fileName = file.getCanonicalPath(); final boolean accept = pattern.matcher(fileName).matches(); if (accept) { retval.add(fileName); } } catch (final IOException e) { throw new ResourceCopyingError("Could not read from the JAR file", e); } } } } } return retval; }
private Collection<String> getResourcesFromDirectory(final File directory, final Pattern pattern) { final ArrayList<String> retval = new ArrayList<String>(); final File[] fileList = directory.listFiles(); if (fileList != null) { for (final File file : fileList) { if (file.isDirectory() && (file.exists())) { retval.addAll(getResourcesFromDirectory(file, pattern)); } else { if (file.exists()) { try { final String fileName = file.getCanonicalPath(); final boolean accept = pattern.matcher(fileName).matches(); if (accept) { retval.add(fileName); } } catch (final IOException e) { throw new ResourceCopyingError("Could not read from the JAR file", e); } } } } } return retval; }