List of usage examples for java.io File pathSeparator
String pathSeparator
To view the source code for java.io File pathSeparator.
Click Source Link
From source file:com.asakusafw.runtime.util.hadoop.ConfigurationProvider.java
private static File findHadoopCommandFromPath(Map<String, String> envp) { String path = envp.get(ENV_PATH); if (path != null && path.trim().isEmpty() == false) { String[] pathPrefixArray = path.split(Pattern.quote(File.pathSeparator)); for (String prefix : pathPrefixArray) { String p = prefix.trim(); if (p.isEmpty()) { continue; }//from ww w.j av a 2 s .c om File bin = new File(p); if (bin.isDirectory() == false) { continue; } File command = new File(bin, PATH_HADOOP_COMMAND_FILE); if (command.canExecute()) { return command; } } } return null; }
From source file:io.jmnarloch.cd.go.plugin.gradle.GradleTaskConfigParser.java
/** * Finds first matching path to executable file by iterating over all system path entries. * * @param command the command//from w ww .java 2 s . c om * @return the absolute path to the executable file */ private String getExecutablePath(String command) { final String systemPath = getEnvironmentVariable(PATH); if (StringUtils.isBlank(systemPath)) { return command; } final String[] paths = systemPath.split(File.pathSeparator); for (String path : paths) { if (Files.exists(Paths.get(path, command))) { return Paths.get(path, command).toAbsolutePath().normalize().toString(); } } return command; }
From source file:nu.nethome.home.items.web.GraphServlet.java
private String getFullFileName(String fileName) { if (fileName.contains(File.pathSeparator) || fileName.contains("/")) { return fileName; } else {/*from w w w.j a v a 2 s. co m*/ return server.getConfiguration().getLogDirectory() + fileName; } }
From source file:org.codehaus.mojo.cobertura.integration.shell.PlainJvmCommandLine.java
/** * Joins all classpathEntries into a proper classpath, as required by a forked Cobertura process. * * @return the Classpath string which could be used for invoking a forked Cobertura process. * @throws java.lang.IllegalStateException if any taskClasspathArtifact could not be resolved to a canonical * path (i.e. its JAR file could not be located, or equivalent). *///w w w.j ava 2 s . c om private String synthesizeClasspath() throws IllegalStateException { final StringBuilder builder = new StringBuilder(); for (Artifact current : classpathEntries) { try { // Get the path to the Artifact final String artifactPath = current.getFile().getCanonicalPath(); // Append the artifact file path to the builder. builder.append(File.pathSeparator).append(artifactPath); } catch (IOException e) { throw new IllegalStateException("Could not find canonical path for '" + current.getFile() + "'.", e); } } // All done. return modifyClasspath(builder.toString()); }
From source file:org.apache.accumulo.core.client.ClientConfiguration.java
private static List<String> getDefaultSearchPath() { String clientConfSearchPath = getClientConfPath(System.getenv("ACCUMULO_CLIENT_CONF_PATH")); List<String> clientConfPaths; if (clientConfSearchPath != null) { clientConfPaths = Arrays.asList(clientConfSearchPath.split(File.pathSeparator)); } else {/*from ww w . jav a 2 s . com*/ // if $ACCUMULO_CLIENT_CONF_PATH env isn't set, priority from top to bottom is: // ~/.accumulo/config // $ACCUMULO_CONF_DIR/client.conf -OR- $ACCUMULO_HOME/conf/client.conf (depending on whether $ACCUMULO_CONF_DIR is set) // /etc/accumulo/client.conf clientConfPaths = new LinkedList<String>(); clientConfPaths.add(System.getProperty("user.home") + File.separator + USER_ACCUMULO_DIR_NAME + File.separator + USER_CONF_FILENAME); if (System.getenv("ACCUMULO_CONF_DIR") != null) { clientConfPaths.add(System.getenv("ACCUMULO_CONF_DIR") + File.separator + GLOBAL_CONF_FILENAME); } else if (System.getenv("ACCUMULO_HOME") != null) { clientConfPaths.add(System.getenv("ACCUMULO_HOME") + File.separator + "conf" + File.separator + GLOBAL_CONF_FILENAME); } clientConfPaths.add("/etc/accumulo/" + GLOBAL_CONF_FILENAME); clientConfPaths.add("/etc/accumulo/conf/" + GLOBAL_CONF_FILENAME); } return clientConfPaths; }
From source file:com.alibaba.jstorm.daemon.supervisor.SyncSupervisorEvent.java
private String resourcesJar() { String path = System.getProperty("java.class.path"); if (path == null) { return null; }// ww w . j a v a 2 s . c om String[] paths = path.split(File.pathSeparator); List<String> jarPaths = new ArrayList<String>(); for (String s : paths) { if (s.endsWith(".jar")) { jarPaths.add(s); } } /** * FIXME, this place seems exist problem */ List<String> rtn = new ArrayList<String>(); int size = jarPaths.size(); for (int i = 0; i < size; i++) { if (JStormUtils.zipContainsDir(jarPaths.get(i), StormConfig.RESOURCES_SUBDIR)) { rtn.add(jarPaths.get(i)); } } if (rtn.size() == 0) return null; return rtn.get(0); }
From source file:org.apache.zeppelin.spark.DepInterpreter.java
private List<File> currentClassPath() { List<File> paths = classPath(Thread.currentThread().getContextClassLoader()); String[] cps = System.getProperty("java.class.path").split(File.pathSeparator); if (cps != null) { for (String cp : cps) { paths.add(new File(cp)); }/* ww w. j av a 2 s .c om*/ } return paths; }
From source file:org.jenkinsci.plugins.neoload.integration.supporting.PluginUtils.java
/** * Check if the given string points to a file on local machine. * If it's not the case, just display an info message, not a warning because * it might be executed on a remote host. * * @param file the file/*w w w . j a v a 2 s. c o m*/ * @param extension the extension * @param checkExtension the check extension * @param checkInPath the check in path * @return the form validation */ public static FormValidation validateFileExists(String file, final String extension, final boolean checkExtension, final boolean checkInPath) { // If file is null or empty, return an error final FormValidation emptyOrNullValidation = FormValidation.validateRequired(file); if (!FormValidation.Kind.OK.equals(emptyOrNullValidation.kind)) { return emptyOrNullValidation; } if (checkExtension && !file.toLowerCase().endsWith(extension)) { return FormValidation.error("Please specify a file with " + extension + " extension"); } // insufficient permission to perform validation? if (!Jenkins.getInstance().hasPermission(Jenkins.ADMINISTER)) { return FormValidation.ok("Insufficient permission to perform legend validation."); } if (file.indexOf(File.separatorChar) >= 0) { // this is full legend File f = new File(file); if (f.exists()) return FileValidator.NOOP.validate(f); File fexe = new File(file + extension); if (fexe.exists()) return FileValidator.NOOP.validate(fexe); } if (Files.exists(Paths.get(file))) { return FormValidation.ok(); } if (checkInPath) { String path = EnvVars.masterEnvVars.get("PATH"); String delimiter = null; if (path != null) { for (String _dir : Util.tokenize(path.replace("\\", "\\\\"), File.pathSeparator)) { if (delimiter == null) { delimiter = ", "; } File dir = new File(_dir); File f = new File(dir, file); if (f.exists()) return FileValidator.NOOP.validate(f); File fexe = new File(dir, file + ".exe"); if (fexe.exists()) return FileValidator.NOOP.validate(fexe); } } } return FormValidation.ok( "There is no such file on local host. You can ignore this message if the job is executed on a remote slave."); }
From source file:net.pms.configuration.WindowsProgramPaths.java
/** * @return The Windows {@code PATHEXT} environment variable as a * {@link List} of {@link String}s containing the extensions without * the {@code .}.//from w w w. j ava2 s . c om */ @Nonnull public static List<String> getWindowsPathExtensions() { List<String> result = new ArrayList<>(); String osPathExtensions = System.getenv("PATHEXT"); if (isBlank(osPathExtensions)) { return result; } String[] extensions = osPathExtensions.split(File.pathSeparator); for (String extension : extensions) { result.add(extension.replace(".", "")); } return result; }
From source file:io.druid.initialization.Initialization.java
public static List<URL> getURLsForClasspath(String cp) { try {/* w ww .java 2s . c om*/ String[] paths = cp.split(File.pathSeparator); List<URL> urls = new ArrayList<>(); for (int i = 0; i < paths.length; i++) { File f = new File(paths[i]); if ("*".equals(f.getName())) { File parentDir = f.getParentFile(); if (parentDir.isDirectory()) { File[] jars = parentDir.listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name != null && (name.endsWith(".jar") || name.endsWith(".JAR")); } }); for (File jar : jars) { urls.add(jar.toURI().toURL()); } } } else { urls.add(new File(paths[i]).toURI().toURL()); } } return urls; } catch (IOException ex) { throw Throwables.propagate(ex); } }