List of usage examples for java.util Vector addAll
public boolean addAll(Collection<? extends E> c)
From source file:tools.httpserver.custom.ScriptList.java
/** * Check pending errors for given script * @param filename The script filename (as stored on disk) to check * @return Pending error or empty script if none *//*from w ww .j a v a2s. co m*/ public static String checkScriptErrors(String filename) { SpoonScript script; try { File scriptfile = new File(filename); Vector<SpoonScript> scripts = new Vector<SpoonScript>( Arrays.asList(icap.services.GreasySpoon.reqSpoonScripts)); scripts.addAll(Arrays.asList(icap.services.GreasySpoon.respSpoonScripts)); for (int i = 0; i < scripts.size(); i++) { script = scripts.elementAt(i); if (script.getFile().equals(scriptfile)) { return script.getPendingErrors(); } } } catch (Exception e) { //e.printStackTrace(); } return ""; }
From source file:tools.httpserver.custom.ScriptList.java
/** * Force script refresh /* w w w .j a va 2s.c o m*/ * @param filename The script to reload * @return Pending error(s) if any, empty string otherwise */ public static String refreshScript(String filename) { SpoonScript script; try { File scriptfile = new File(filename); Vector<SpoonScript> scripts = new Vector<SpoonScript>( Arrays.asList(icap.services.GreasySpoon.reqSpoonScripts)); scripts.addAll(Arrays.asList(icap.services.GreasySpoon.respSpoonScripts)); for (int i = 0; i < scripts.size(); i++) { script = scripts.elementAt(i); if (script.getFile().equals(scriptfile)) { script.refresh(); return script.getPendingErrors(); } } } catch (Exception e) { return e.getLocalizedMessage(); } return ""; }
From source file:edu.umn.cs.spatialHadoop.mapred.FileSplitUtil.java
/** * Combines a number of file splits into one CombineFileSplit. If number of * splits to be combined is one, it returns this split as is without creating * a CombineFileSplit.// w w w .j a va2 s .c o m * @param splits * @param startIndex * @param count * @return * @throws IOException */ public static InputSplit combineFileSplits(JobConf conf, List<FileSplit> splits, int startIndex, int count) throws IOException { if (count == 1) { return splits.get(startIndex); } else { Path[] paths = new Path[count]; long[] starts = new long[count]; long[] lengths = new long[count]; Vector<String> vlocations = new Vector<String>(); while (count > 0) { paths[count - 1] = splits.get(startIndex).getPath(); starts[count - 1] = splits.get(startIndex).getStart(); lengths[count - 1] = splits.get(startIndex).getLength(); vlocations.addAll(Arrays.asList(splits.get(startIndex).getLocations())); count--; startIndex++; } String[] locations = prioritizeLocations(vlocations); if (locations.length > 3) { String[] topLocations = new String[3]; System.arraycopy(locations, 0, topLocations, 0, topLocations.length); locations = topLocations; } return new CombineFileSplit(conf, paths, starts, lengths, locations); } }
From source file:edu.umn.cs.spatialHadoop.mapred.FileSplitUtil.java
/** * Combines a number of file splits into one CombineFileSplit (mapreduce). If * number of splits to be combined is one, it returns this split as is without * creating a CombineFileSplit.//from w ww . j a v a 2 s .c o m * * @param splits * @param startIndex * @param count * @return * @throws IOException */ public static org.apache.hadoop.mapreduce.InputSplit combineFileSplits( List<org.apache.hadoop.mapreduce.lib.input.FileSplit> splits, int startIndex, int count) throws IOException { if (count == 1) { return splits.get(startIndex); } else { Path[] paths = new Path[count]; long[] starts = new long[count]; long[] lengths = new long[count]; Vector<String> vlocations = new Vector<String>(); while (count > 0) { paths[count - 1] = splits.get(startIndex).getPath(); starts[count - 1] = splits.get(startIndex).getStart(); lengths[count - 1] = splits.get(startIndex).getLength(); vlocations.addAll(Arrays.asList(splits.get(startIndex).getLocations())); count--; startIndex++; } String[] locations = prioritizeLocations(vlocations); if (locations.length > 3) { String[] topLocations = new String[3]; System.arraycopy(locations, 0, topLocations, 0, topLocations.length); locations = topLocations; } return new org.apache.hadoop.mapreduce.lib.input.CombineFileSplit(paths, starts, lengths, locations); } }
From source file:jenkins.plugins.coverity.CoverityUtils.java
public static Collection<File> listFiles(File directory, FilenameFilter filter, boolean recurse) { Vector<File> files = new Vector<File>(); File[] entries = directory.listFiles(); if (entries == null) { return files; }/*from w w w .j ava 2 s .c o m*/ for (File entry : entries) { if (filter == null || filter.accept(directory, entry.getName())) { files.add(entry); } if (recurse && entry.isDirectory()) { files.addAll(listFiles(entry, filter, recurse)); } } return files; }
From source file:com.qmetry.qaf.automation.util.FileUtil.java
public static Collection<File> listFiles(File directory, FilenameFilter filter, boolean recurse) { // List of files / directories Vector<File> files = new Vector<File>(); // Get files / directories in the directory File[] entries = directory.listFiles(); // Go over entries for (File entry : entries) { if ((filter == null) || filter.accept(directory, entry.getName())) { files.add(entry);/*ww w. j a va 2s. co m*/ } // If the file is a directory and the recurse flag // is set, recurse into the directory if (recurse && entry.isDirectory() && !entry.isHidden()) { files.addAll(listFiles(entry, filter, recurse)); } } // Return collection of files return files; }
From source file:com.qmetry.qaf.automation.util.FileUtil.java
public static Collection<File> getFiles(File directory, String name, StringComparator c, boolean recurse) { // List of files / directories Vector<File> files = new Vector<File>(); // Get files / directories in the directory File[] entries = directory.listFiles(); FilenameFilter filter = getFileFilterFor(name, c); // Go over entries for (File entry : entries) { if ((filter == null) || filter.accept(directory, entry.getName())) { files.add(entry);//w ww . ja va 2s. com } // If the file is a directory and the recurse flag // is set, recurse into the directory if (recurse && entry.isDirectory()) { files.addAll(listFiles(entry, filter, recurse)); } } // Return collection of files return files; }
From source file:com.qmetry.qaf.automation.util.FileUtil.java
public static Collection<File> getFiles(File directory, String extension, boolean recurse) { // List of files / directories Vector<File> files = new Vector<File>(); // Get files / directories in the directory File[] entries = directory.listFiles(); FilenameFilter filter = getFileFilterFor(extension, StringComparator.Suffix); // Go over entries for (File entry : entries) { if ((filter == null) || filter.accept(directory, entry.getName())) { files.add(entry);/*w w w . j av a 2 s .com*/ } // If the file is a directory and the recurse flag // is set, recurse into the directory if (recurse && entry.isDirectory()) { files.addAll(listFiles(entry, filter, recurse)); } } // Return collection of files return files; }
From source file:pt.lsts.neptus.plugins.europa.EuropaUtils.java
protected static String locateLibrary(String lib) throws Exception { String lookFor = System.mapLibraryName(lib); Vector<String> path = new Vector<>(); switch (CheckJavaOSArch.getOs()) { case "linux-x64": path.add(new File("libJNI/europa/x64").getAbsolutePath()); break;//www .java 2 s. co m default: break; } String ldPath = System.getenv("LD_LIBRARY_PATH"), europa = System.getenv("EUROPA_HOME"); // Check for explicit info about europa location if (europa == null) { // Attempt to get PLASMA_HOME instead europa = System.getenv("PLASMA_HOME"); } if (europa != null && new File(europa).isDirectory()) path.add(europa + File.separator + "lib"); // Get the java library path where jnilibs are expected to be path.addAll(Arrays.asList(System.getProperty("java.library.path").split(File.pathSeparator))); // finally add LD_LIBRARY_PATH if it exists if (ldPath != null) { path.addAll(Arrays.asList(ldPath.split(File.pathSeparator))); } // Now iterate through all these paths to locate the library for (String s : path) { File f = new File(s, lookFor); if (f.exists()) { // found it => return the fully qualified path return f.getAbsolutePath(); } } // If we reach this point the library was nowhere to be found throw new FileNotFoundException("Library " + System.mapLibraryName(lib) + " was not found in " + StringUtils.join(path, File.pathSeparator)); }
From source file:org.openflexo.toolbox.FileUtils.java
public static Vector<File> listFilesRecursively(File dir, final FilenameFilter filter) { if (!dir.isDirectory()) { return null; }/*from ww w . ja v a 2 s.c om*/ Vector<File> files = new Vector<File>(); File[] f = dir.listFiles(); for (int i = 0; i < f.length; i++) { File file = f[i]; if (file.isDirectory()) { files.addAll(listFilesRecursively(file, filter)); } else if (filter.accept(dir, file.getName())) { files.add(file); } } return files; }