private Collection<String> getResourcesFromJarFile(final File file, final Pattern pattern) { final ArrayList<String> retval = new ArrayList<String>(); if (file.exists()) { ZipFile zf; try { zf = zipFileFor(file); } catch (final IOException e) { throw new ResourceCopyingError("Could not read from the JAR file", e); } @SuppressWarnings("rawtypes") final Enumeration e = zf.entries(); while (e.hasMoreElements()) { final ZipEntry ze = (ZipEntry) e.nextElement(); final String fileName = ze.getName(); final boolean accept = pattern.matcher(fileName).matches(); if (accept) { retval.add(fileName); } } try { zf.close(); } catch (final IOException e1) { throw new ResourceCopyingError("Couldn't close the zip file", e1); } } return retval; }
private Collection<String> getResourcesFromJarFile(final File file, final Pattern pattern) { final ArrayList<String> retval = new ArrayList<String>(); if (file.exists()) { ZipFile zf; try { zf = zipFileFor(file); } catch (final IOException e) { throw new ResourceCopyingError("Could not read from the JAR file", e); } @SuppressWarnings("rawtypes") final Enumeration e = zf.entries(); while (e.hasMoreElements()) { final ZipEntry ze = (ZipEntry) e.nextElement(); final String fileName = ze.getName(); final boolean accept = pattern.matcher(fileName).matches(); if (accept) { retval.add(fileName); } } try { zf.close(); } catch (final IOException e1) { throw new ResourceCopyingError("Couldn't close the zip file", e1); } } return retval; }
private Collection<String> getResourcesFromJarFile(final File file, final Pattern pattern) { final ArrayList<String> matchingResources = new ArrayList<>(); try{ if (file.exists()) { try (ZipFile zf = zipFileFor(file)) { @SuppressWarnings("rawtypes") final Enumeration e = zf.entries(); while (e.hasMoreElements()) { final ZipEntry entry = (ZipEntry) e.nextElement(); final String fileName = entry.getName(); if (resourceDirectory.isEmpty() || fileName.contains(resourceDirectory)) { if (pattern.matcher(fileName).matches()) { matchingResources.add(fileName); } } } } } } catch (IOException e) { throw new ResourceCopyingError("Couldn't close the zip file " + file, e); } return matchingResources; }
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> 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; }