List of usage examples for java.io File pathSeparatorChar
char pathSeparatorChar
To view the source code for java.io File pathSeparatorChar.
Click Source Link
From source file:com.ansorgit.plugins.bash.util.SystemPathUtil.java
@Nullable public static String findBestExecutable(@NotNull String commandName) { List<String> paths = Arrays.asList(StringUtils.split(System.getenv("PATH"), File.pathSeparatorChar)); return findBestExecutable(commandName, paths); }
From source file:org.appcelerator.locator.ServiceCompiler.java
/** * compile a service file written in Java * //from w w w.ja va2 s.com * @param serviceFile * @param classDir */ public static boolean compileJava(File serviceFile, File classDir, PrintWriter stderr) { if (LOG.isDebugEnabled()) LOG.debug("compiling java service file: " + serviceFile); classDir.mkdirs(); URL[] urls = ClasspathUrlFinder.findClassPaths(); StringBuilder cp = new StringBuilder(); cp.append("\"" + System.getProperty("sun.boot.class.path") + "\""); cp.append(File.pathSeparatorChar); for (URL url : urls) { cp.append("\""); cp.append(url.getPath()); cp.append("\""); cp.append(File.pathSeparatorChar); } StringWriter errWriter = new StringWriter(); StringBuffer buf = errWriter.getBuffer(); // calculate the source version to use with the compiler. we support a new custom system // property called java.compiler.version which can be set to specifically use a different version // otherwise we default to 1.5 String ver = System.getProperty("java.compiler.version", "1.5"); boolean success = Main .compile( "-g -source " + ver + " -cp " + cp + " -d " + classDir + " \"" + serviceFile.getAbsolutePath() + "\"", new PrintWriter(System.out, true), new PrintWriter(errWriter, true)); stderr.print(buf.toString()); stderr.flush(); return success; }
From source file:com.github.blindpirate.gogradle.core.cache.DirectorySnapshot.java
private static String md5(File projectRoot, File targetDir) { List<File> allFilesInDir = IOUtils.listAllDescendents(targetDir).stream().sorted(File::compareTo) .collect(Collectors.toList()); StringBuilder sb = new StringBuilder(); allFilesInDir.forEach(file -> {/* w w w . ja va 2s. co m*/ Path relativePath = projectRoot.toPath().relativize(file.toPath()); sb.append(file.isFile() ? "f" : "d").append(File.pathSeparatorChar).append(toUnixString(relativePath)) .append(File.pathSeparatorChar).append(file.length()).append(File.pathSeparatorChar) .append(file.lastModified()).append(File.pathSeparatorChar); }); return DigestUtils.md5Hex(sb.toString()); }
From source file:org.clickframes.util.JarResourceUtil.java
public static File copyTemplatesFromJarToTempDirectory(String jarFileName, String autoscanDirectoryName) throws IOException { // String jarName = "clickframes-webflow-plugin"; // String AUTOSCAN_DIR = "/autoscan/"; final String classpath = System.getProperty("java.class.path"); String[] classpathArray = classpath.split(File.pathSeparatorChar + ""); logger.debug("classpath = " + classpath); for (String classpathJar : classpathArray) { logger.debug("jar = " + classpathJar); if (classpathJar.contains(jarFileName)) { JarFile jarFile = new JarFile(classpathJar); File temporaryFolder = new File(System.getProperty("java.io.tmpdir"), "autoscanTempDir"); temporaryFolder.mkdirs();/*from w w w.ja v a2 s.co m*/ temporaryFolder.deleteOnExit(); // list all entries in jar Enumeration<JarEntry> resources = jarFile.entries(); while (resources.hasMoreElements()) { JarEntry je = resources.nextElement(); final String fileInJar = je.getName(); // if autoscan target, copy to temp folder if (fileInJar.contains(autoscanDirectoryName)) { copyFile(jarFile, temporaryFolder, je, fileInJar); } } return temporaryFolder; } } throw new RuntimeException("We're sorry, we couldn't find your jar"); }
From source file:com.granita.contacticloudsync.log.ExternalFileLogger.java
public ExternalFileLogger(Context context, String fileName, boolean verbose) throws IOException { this.verbose = verbose; File dir = getDirectory(context); if (dir == null) throw new IOException("External media not available for log creation"); name = StringUtils.remove(StringUtils.remove(fileName, File.pathSeparatorChar), File.separatorChar); File log = new File(dir, name); writer = new PrintWriter(log); }
From source file:org.jenkinsci.plugins.durabletask.WindowsBatchScriptTest.java
@BeforeClass public static void windows() { Assume.assumeTrue("These tests are only for Windows", File.pathSeparatorChar == ';'); }
From source file:put.semantic.fcanew.preferences.PreferencesProvider.java
public List<File> getFiles() { String filesString = getNode().get("files", ""); if (filesString == null) { return Collections.EMPTY_LIST; }//from w ww .j a v a 2s . c om List<File> result = new ArrayList<>(); String[] paths = StringUtils.split(filesString, File.pathSeparatorChar); for (String path : paths) { File f = new File(path); if (f.isFile() && f.canRead()) { result.add(f); } } return result; }
From source file:com.twosigma.beakerx.groovy.evaluator.GroovyClassLoaderFactory.java
public static GroovyClassLoader newEvaluator(Imports imports, Classpath classpath, String outDir, ImportCustomizer icz, ClassLoader parent) { try {/*from w ww .ja v a 2 s .c om*/ Class.forName("org.codehaus.groovy.control.customizers.ImportCustomizer"); } catch (ClassNotFoundException e1) { String gjp = System.getenv(GROOVY_JAR_PATH); String errorMsg = null; if (gjp != null && !gjp.isEmpty()) { errorMsg = "Groovy libary not found, GROOVY_JAR_PATH = " + gjp; } else { errorMsg = "Default groovy libary not found. No GROOVY_JAR_PATH variable set."; } throw new GroovyNotFoundException(errorMsg); } icz = addImportsCustomizer(icz, imports); CompilerConfiguration config = new CompilerConfiguration().addCompilationCustomizers(icz); String acloader_cp = String.join(File.pathSeparatorChar + "", classpath.getPathsAsStrings()); config.setClasspath(acloader_cp); return new GroovyClassLoader(parent, config); }
From source file:put.semantic.fcanew.preferences.PreferencesProvider.java
public void setFiles(Iterable<File> data) { List<String> paths = new ArrayList<>(); for (File f : data) { paths.add(f.getAbsolutePath());// www .j a v a 2 s.c om } String files = StringUtils.join(paths, File.pathSeparatorChar); getNode().put("files", files); }
From source file:Main.java
/** * Splits apart a OS separator delimited set of paths in a string into * multiple Strings. File component path strings are returned within a List * in the order they are found in the composite path string. Optionally, a * file filter can be used to filter out path strings to control the * components returned. If the filter is null all path components are * returned.//from w w w.j a va 2 s.c om * * @param paths * a set of paths delimited using the OS path separator * @param filter * a FileFilter used to filter the return set * @return the filter accepted path component Strings in the order * encountered */ public static final List getPaths(String paths, FileFilter filter) { int start = 0; int stop = -1; String path = null; ArrayList<String> list = new ArrayList<String>(); // Abandon with no values if paths string is null if (paths == null || paths.trim().equals("")) { return list; } final int max = paths.length() - 1; // Loop spliting string using OS path separator: terminate // when the start index is at the end of the paths string. while (start < max) { stop = paths.indexOf(File.pathSeparatorChar, start); // The is no file sep between the start and the end of the string if (stop == -1) { // If we have a trailing path remaining without ending separator if (start < max) { // Last path is everything from start to the string's end path = paths.substring(start); // Protect against consecutive separators side by side if (!path.trim().equals("")) { // If filter is null add path, if it is not null add the // path only if the filter accepts the path component. if (filter == null || filter.accept(new File(path))) { list.add(path); } } } break; // Exit loop no more path components left! } // There is a separator between start and the end if we got here! // start index is now at 0 or the index of last separator + 1 // stop index is now at next separator in front of start index path = paths.substring(start, stop); // Protect against consecutive separators side by side if (!path.trim().equals("")) { // If filter is null add path, if it is not null add the path // only if the filter accepts the path component. if (filter == null || filter.accept(new File(path))) { list.add(path); } } // Advance start index past separator to start of next path comp start = stop + 1; } return list; }