List of usage examples for java.util ArrayList addAll
public boolean addAll(Collection<? extends E> c)
From source file:de.netallied.functionblock.converter.java2java.util.Directory.java
/** * *///from ww w. j a v a 2 s.c om public static ArrayList getAllDirs(File folder, boolean recursive) { ArrayList list = new ArrayList(); File[] files = folder.listFiles(); if (files == null) return list; for (int i = 0; i < files.length; i++) { if (files[i].isDirectory()) { list.add(files[i]); if (recursive) list.addAll(getAllDirs(files[i], recursive)); } } return list; }
From source file:Main.java
public static ArrayList<File> getFilesArray(String path) { File file = new File(path); File files[] = file.listFiles(); ArrayList<File> listFile = new ArrayList<File>(); if (files != null) { for (int i = 0; i < files.length; i++) { if (files[i].isFile()) { listFile.add(files[i]);/*from w w w . ja va 2 s . c o m*/ } if (files[i].isDirectory()) { listFile.addAll(getFilesArray(files[i].toString())); } } } return listFile; }
From source file:com.termmed.utils.ResourceUtils.java
/** * Gets the resources./* ww w .j av a 2 s .c o m*/ * * @param element the element * @param pattern the pattern * @return the resources */ private static Collection<String> getResources(final String element, final Pattern pattern) { final ArrayList<String> retval = new ArrayList<String>(); final File file = new File(element); if (file.isDirectory()) { retval.addAll(getResourcesFromDirectory(file, pattern)); } else { retval.addAll(getResourcesFromJarFile(file, pattern)); } return retval; }
From source file:org.uimafit.factory.TypeSystemDescriptionFactory.java
/** * Scan patterns from manifest files and from the specified system property. * * @param manifestPatterns pattern matching the manifest files. * @param importProperty system property containing additional patterns. * @return array or all patterns found.//from w ww.j a va2 s .co m */ public static String[] scanImportsAndManifests(String manifestPatterns, String importProperty) throws ResourceInitializationException { ArrayList<String> patterns = new ArrayList<String>(); // Scan auto-import locations patterns.addAll(Arrays.asList(System.getProperty(importProperty, "").split(";"))); // Scan manifest for (String mfUrl : resolve(manifestPatterns)) { InputStream is = null; try { is = new URL(mfUrl).openStream(); @SuppressWarnings("unchecked") List<? extends String> lines = IOUtils.readLines(is); patterns.addAll(lines); } catch (IOException e) { throw new ResourceInitializationException(e); } finally { IOUtils.closeQuietly(is); } } return patterns.toArray(new String[patterns.size()]); }
From source file:com.offbynull.coroutines.instrumenter.testhelpers.TestUtils.java
/** * Gets the system classpath and creates a list of {@link File} objects for each path. * * @return classpath as list of {@link File} objects * @throws IllegalStateException if the classpath doesn't exist or can't be split up *///w ww . ja v a2s . c o m public static List<File> getClasspath() { String pathSeparator = System.getProperty("path.separator"); Validate.validState(pathSeparator != null); String classpath = System.getProperty("java.class.path"); Validate.validState(classpath != null); List<File> classPathFiles = Arrays.stream(classpath.split(Pattern.quote(pathSeparator))) .map(x -> new File(x)).filter(x -> x.exists()).collect(Collectors.toList()); String bootClasspath = System.getProperty("sun.boot.class.path"); Validate.validState(bootClasspath != null); List<File> bootClassPathFiles = Arrays.stream(bootClasspath.split(Pattern.quote(pathSeparator))) .map(x -> new File(x)).filter(x -> x.exists()).collect(Collectors.toList()); ArrayList<File> ret = new ArrayList<>(); ret.addAll(classPathFiles); ret.addAll(bootClassPathFiles); return ret; }
From source file:is.iclt.icenlp.core.utils.FileOperations.java
public static ArrayList<String> getFilePaths(String folderPath) { File rootFolder = new File(folderPath); File[] rootFiles = rootFolder.listFiles(); ArrayList<String> filePaths = new ArrayList<String>(); for (int i = 0; i < rootFiles.length; i++) { String lFolderPath = rootFiles[i].getAbsolutePath(); // l = local if (rootFiles[i].isDirectory()) { filePaths.addAll(getFilePaths(lFolderPath)); } else if (rootFiles[i].isFile()) { filePaths.add(lFolderPath);/* ww w . jav a 2s .c o m*/ } } return filePaths; }
From source file:key.secretkey.utils.PasswordStorage.java
/** * Gets the .gpg files in a directory/*from w ww.ja va 2s. co m*/ * @param path the directory path * @return the list of gpg files in that directory */ public static ArrayList<File> getFilesList(File path) { if (!path.exists()) return new ArrayList<File>(); Log.d("REPO", "current path: " + path.getPath()); ArrayList<File> files = new ArrayList<File>( Arrays.asList(path.listFiles((FileFilter) FileFilterUtils.directoryFileFilter()))); files.addAll(new ArrayList<File>((List<File>) FileUtils.listFiles(path, new String[] { "gpg" }, false))); return new ArrayList<File>(files); }
From source file:com.piggate.sdk.PiggateOffers.java
public static ArrayList<PiggateOffers> getOffers() { Lock l = rwLock2.readLock();//from ww w . j av a 2 s .co m ArrayList<PiggateOffers> result = new ArrayList<PiggateOffers>(); l.lock(); try { result.addAll(internal_offers); } catch (Exception ex) { } finally { l.unlock(); } return result; }
From source file:com.excelsiorjet.api.util.Utils.java
public static String[] prepend(String firstElement, String[] remaining) { if (remaining == null) { return new String[] { firstElement }; }/* w w w. j a va 2 s . c o m*/ ArrayList<String> res = new ArrayList<>(); res.add(firstElement); res.addAll(Arrays.asList(remaining)); return res.toArray(new String[remaining.length + 1]); }
From source file:com.ikanow.aleph2.harvest.logstash.utils.LogstashUtils.java
/** Builds a process to execute * @param global//from ww w . j a v a 2 s . c om * @param bucket_config * @param logstash_config * @param requested_docs * @param bucket_path if this is present, will log output to /tmp/unique_sig * @param context * @return */ public static ProcessBuilder buildLogstashTest(final LogstashHarvesterConfigBean global, final LogstashBucketConfigBean bucket_config, final String logstash_config, final long requested_docs, final Optional<String> bucket_path) { final String log_file = System.getProperty("java.io.tmpdir") + File.separator + BucketUtils.getUniqueSignature(bucket_path.orElse("DNE"), Optional.empty()); try { //(delete log file if it exists) new File(log_file).delete(); } catch (Exception e) { } ArrayList<String> args = new ArrayList<String>(); args.addAll(Arrays.asList(global.binary_path(), "-e", logstash_config)); if (bucket_path.isPresent()) { args.addAll(Arrays.asList("-l", log_file)); } if (0L == requested_docs) { args.add("-t"); // test mode, must faster } //TESTED if (bucket_config.debug_verbosity()) { args.add("--debug"); } else { args.add("--verbose"); } ProcessBuilder logstashProcessBuilder = new ProcessBuilder(args); logstashProcessBuilder = logstashProcessBuilder.directory(new File(global.working_dir())) .redirectErrorStream(true); logstashProcessBuilder.environment().put("JAVA_OPTS", ""); return logstashProcessBuilder; }