Example usage for java.io File pathSeparatorChar

List of usage examples for java.io File pathSeparatorChar

Introduction

In this page you can find the example usage for java.io File pathSeparatorChar.

Prototype

char pathSeparatorChar

To view the source code for java.io File pathSeparatorChar.

Click Source Link

Document

The system-dependent path-separator character.

Usage

From source file:org.apache.reef.runtime.common.launch.JavaLaunchCommandBuilder.java

public JavaLaunchCommandBuilder setClassPath(final Collection<String> classPathElements) {
    this.classPath = StringUtils.join(classPathElements, File.pathSeparatorChar);
    return this;
}

From source file:org.springsource.ide.eclipse.commons.internal.configurator.Configurator.java

private void persistRequest(String target) {
    String configureTargets = Activator.getDefault().getPreferenceStore()
            .getString(Activator.PROPERTY_CONFIGURE_TARGETS);
    if (StringUtils.hasLength(configureTargets)) {
        configureTargets += File.pathSeparatorChar + target;
    } else {//from   www .j ava  2 s. com
        configureTargets = target;
    }
    Activator.getDefault().getPreferenceStore().setValue(Activator.PROPERTY_CONFIGURE_TARGETS,
            configureTargets);
}

From source file:org.daisy.pipeline.execution.rmi.PoolableRMIPipelineInstanceFactory.java

private String buildClassPath() {
    StringBuilder sb = new StringBuilder();
    sb.append(".").append(File.pathSeparatorChar);
    if (new File(pipelineDir, "bin").exists()) {
        sb.append("bin").append(File.separatorChar).append(File.pathSeparatorChar);
    } else {/*from  w  ww . j a v  a2s  .com*/
        sb.append("pipeline.jar").append(File.pathSeparatorChar);
    }
    for (File file : new File(pipelineDir, "lib").listFiles(new FileFilter() {
        public boolean accept(File pathname) {
            return pathname.isFile() && pathname.getName().endsWith(".jar");
        }
    })) {
        sb.append(pipelineDir.toURI().relativize(file.toURI()).getPath()).append(File.pathSeparatorChar);
    }
    sb.deleteCharAt(sb.length() - 1);
    return sb.toString();
}

From source file:com.twosigma.beaker.groovy.utils.GroovyEvaluator.java

public void setShellOptions(String cp, String in, String od) throws IOException {
    if (od == null || od.isEmpty()) {
        od = FileSystems.getDefault().getPath(System.getenv("beaker_tmp_dir"), "dynclasses", sessionId)
                .toString();//  w ww. j a v  a 2  s. c om
    } else {
        od = od.replace("$BEAKERDIR", System.getenv("beaker_tmp_dir"));
    }

    // check if we are not changing anything
    if (currentClassPath.equals(cp) && currentImports.equals(in) && outDirInput.equals(od))
        return;

    currentClassPath = cp;
    currentImports = in;
    Map<String, String> env = System.getenv();
    outDirInput = od;
    outDir = envVariablesFilter(od, env);

    if (cp.isEmpty())
        classPath = new ArrayList<String>();
    else {
        List<String> cpList = new ArrayList<String>();
        for (String p : Arrays.asList(cp.split("[\\s" + File.pathSeparatorChar + "]+"))) {

            p = envVariablesFilter(p, env);

            cpList.add(p);
        }
        classPath = cpList;
    }

    if (!in.isEmpty()) {
        String[] importLines = in.split("\\n+");
        for (String line : importLines) {
            if (!line.trim().isEmpty()) {
                imports.add(line);
            }
        }
    }

    try {
        (new File(outDir)).mkdirs();
    } catch (Exception e) {
    }

    resetEnvironment();
}

From source file:rita.settings.Settings.java

protected static File getWindowsConfigPath() throws SecurityException {
    /* Es Windows Vista o Windows 7? */
    String appDataDir = System.getenv("LOCALAPPDATA");
    if (appDataDir == null) {
        /* No tiene definido LOCALAPPDATA, entonces asumimos que es Windows XP -- averiguamos LocalAppData a traves de la hubicacion del dir "Temp" */
        appDataDir = System.getenv("TEMP");
        if (appDataDir == null) {
            appDataDir = System.getProperty("java.io.tmpdir");
        }/* w  w  w  . j  a v  a2 s .c  o  m*/
        /* quitamos "/Temp" y agregamos "/Application Data" */
        appDataDir = appDataDir.substring(0, appDataDir.lastIndexOf(java.io.File.pathSeparatorChar))
                + java.io.File.pathSeparator + "Application Data";
    }
    File configHomeDir = new File(appDataDir, CONFIG_DIR);
    if (!configHomeDir.exists()) {
        if (!configHomeDir.mkdir()) {
            throw new SecurityException();
        }
    } else if (!configHomeDir.canWrite()) {
        throw new SecurityException();
    }
    return configHomeDir;
}

From source file:org.mxupdate.eclipse.mxadapter.connectors.URLConnector.java

/**
 * Initializes the connection to the MX server.
 *
 * @param _projectPath          path to the project temporary folder
 * @param _bundle               bundle of the plug-in to access the class
 *                              and required libraries for the server
 * @param _javaPath             path for the Java executable
 * @param _mxJarPath            path of the MX Jar library
 * @param _url                  URL of the MX server
 * @param _user                 name of the user on the MX server
 * @param _passwd               password of the user on the MX server
 * @param _updateByFileContent  <i>true</i> if update is done by
 *                              transmitting the file content; otherwise
 *                              <i>false</i>
 * @throws Exception if connection to the MX server could not be started
 *//*from  www .j  ava  2 s  .  c om*/
public URLConnector(final File _projectPath, final Bundle _bundle, final String _javaPath,
        final String _mxJarPath, final String _url, final String _user, final String _passwd,
        final boolean _updateByFileContent) throws Exception {
    super(_updateByFileContent);

    // copy the required classes and JAR library to temporary project dir.
    if (!_projectPath.exists()) {
        _projectPath.mkdirs();
    }
    for (final Class<?> clazz : URLConnector.SERVER_CLASSES) {
        // the URL must use slashes to be a valid URL (and
        // File.separatorChar delivers backslashes in Windows)
        final String clazzFileName = "/" + clazz.getName().replace('.', '/') + ".class";
        this.copy(this.getClass().getClassLoader().getResource(clazzFileName),
                new File(_projectPath, "/bin" + clazzFileName));
    }

    // prepare class path (and always slashes instead of backslashes)
    final StringBuilder classPath = new StringBuilder().append("bin").append('/').append('.')
            .append(File.pathSeparatorChar).append(_mxJarPath.replace('\\', '/'));

    // start process
    final ProcessBuilder pb = new ProcessBuilder(_javaPath, "-classpath", classPath.toString(),
            URLConnectorServer.class.getName(), _url, _user, _passwd);
    pb.directory(_projectPath);

    this.process = pb.start();

    this.out = new OutputStreamWriter(this.process.getOutputStream());
    this.inHandler = new InputStreamHandler(this.process.getInputStream());
    this.errHandler = new ErrorStreamHandler(this.process.getErrorStream());
    new Thread(this.inHandler).start();
    new Thread(this.errHandler).start();

    try {
        this.testConnection();
        this.connected = true;
    } finally {
        if (!this.connected) {
            this.disconnect();
        }
    }
}

From source file:com.twosigma.beaker.groovy.evaluator.GroovyEvaluator.java

@Override
public void setShellOptions(final KernelParameters kernelParameters) throws IOException {
    Map<String, Object> params = kernelParameters.getParams();

    Collection<String> listOfImports = (Collection<String>) params.get(IMPORTS);
    Collection<String> listOfClassPath = (Collection<String>) params.get(CLASSPATH);
    String cp = getAsString(listOfClassPath);
    String in = getAsString(listOfImports);

    // check if we are not changing anything
    if (StringUtils.equals(currentClassPath, cp) && StringUtils.equals(currentImports, in))
        return;/*from  w ww.  jav  a2 s  . c om*/

    currentClassPath = cp;
    currentImports = in;
    Map<String, String> env = System.getenv();

    if (cp == null || cp.isEmpty())
        classPath = new ArrayList<>();
    else {
        List<String> cpList = new ArrayList<>();
        for (String p : Arrays.asList(cp.split("[\\s" + File.pathSeparatorChar + "]+"))) {
            p = envVariablesFilter(p, env);
            cpList.add(p);
        }
        classPath = cpList;
    }

    if (in != null && !in.isEmpty()) {
        String[] importLines = in.split("\\n+");
        for (String line : importLines) {
            if (!line.trim().isEmpty()) {
                imports.add(line);
            }
        }
    }

    try {
        (new File(outDir)).mkdirs();
    } catch (Exception e) {
    }

    resetEnvironment();
}

From source file:org.apache.james.repository.file.AbstractFileRepository.java

@Override
public Repository getChildRepository(String childName) {
    AbstractFileRepository child;/*w w  w .j  av  a 2  s .  c o  m*/

    try {
        child = createChildRepository();
    } catch (Exception e) {
        throw new RuntimeException("Cannot create child repository " + childName + " : " + e);
    }

    child.setFileSystem(fileSystem);
    child.setLog(logger);

    try {
        child.setDestination(
                m_baseDirectory.getAbsolutePath() + File.pathSeparatorChar + childName + File.pathSeparator);
    } catch (ConfigurationException ce) {
        throw new RuntimeException(
                "Cannot set destination for child child " + "repository " + childName + " : " + ce);
    }

    try {
        child.init();
    } catch (Exception e) {
        throw new RuntimeException("Cannot initialize child " + "repository " + childName + " : " + e);
    }

    if (DEBUG) {
        getLogger().debug("Child repository of " + m_name + " created in " + m_baseDirectory
                + File.pathSeparatorChar + childName + File.pathSeparator);
    }

    return child;
}

From source file:org.apache.tajo.yarn.container.WorkerContainerTask.java

private void setupEnv(ContainerLaunchContext amContainer) throws IOException {
    LOG.info("Set the environment for the worker");
    Map<String, String> env = new HashMap<String, String>();

    // Add AppMaster.jar location to classpath
    // At some point we should not be required to add
    // the hadoop specific classpaths to the env.
    // It should be provided out of the box.
    // For now setting all required classpaths including
    // the classpath to "." for the application jar
    StringBuilder classPathEnv = new StringBuilder(ApplicationConstants.Environment.CLASSPATH.$())
            .append(File.pathSeparatorChar).append("./*");

    env.put("CLASSPATH", classPathEnv.toString());
    env.put(Constants.TAJO_ARCHIVE_ROOT, System.getenv(Constants.TAJO_ARCHIVE_ROOT));
    env.put(Constants.TAJO_HOME, "$PWD/${" + Constants.TAJO_ARCHIVE_ROOT + "}");
    env.put(Constants.TAJO_CONF_DIR, "$PWD/conf");
    env.put(Constants.TAJO_LOG_DIR, ApplicationConstants.LOG_DIR_EXPANSION_VAR);
    env.put(Constants.TAJO_CLASSPATH, "/export/apps/hadoop/site/lib/*");
    amContainer.setEnvironment(env);//w w w.java  2s .co  m
}

From source file:com.asakusafw.directio.hive.tools.cli.GenerateCreateTable.java

/**
 * Parses a string of file list separated by the platform dependent path separator.
 * @param fileListOrNull target string, or {@code null}
 * @return the represented file list, or an empty list if not specified
 *///from  w w w .jav  a 2s.c om
private static List<File> parseFileList(String fileListOrNull) {
    if (fileListOrNull == null || fileListOrNull.isEmpty()) {
        return Collections.emptyList();
    }
    List<File> results = new ArrayList<>();
    int start = 0;
    while (true) {
        int index = fileListOrNull.indexOf(File.pathSeparatorChar, start);
        if (index < 0) {
            break;
        }
        if (start != index) {
            results.add(new File(fileListOrNull.substring(start, index).trim()));
        }
        start = index + 1;
    }
    results.add(new File(fileListOrNull.substring(start).trim()));
    return results;
}