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:com.netflix.nicobar.core.utils.__JDKPaths.java

static void processClassPathItem(final String classPath, final Set<String> jarSet, final Set<String> pathSet) {
    if (classPath == null)
        return;/*from  w w  w.j  a v  a 2 s  .  c  o  m*/
    int s = 0, e;
    do {
        e = classPath.indexOf(File.pathSeparatorChar, s);
        String item = e == -1 ? classPath.substring(s) : classPath.substring(s, e);
        if (jarSet != null && !jarSet.contains(item)) {
            final File file = new File(item);
            if (file.isDirectory()) {
                processDirectory0(pathSet, file);
            } else {
                try {
                    processJar(pathSet, file);
                } catch (IOException ex) { // NOPMD
                }
            }
        }
        s = e + 1;
    } while (e != -1);
}

From source file:org.apache.hadoop.hive.ql.debug.Utils.java

/**
 * Dumps process heap to a file in temp directoty.
 * @param args Strings to use to build a file name (dump_arg0_arg1_....).
 *///from w  w w. jav  a 2s  .c o m
public static void dumpHeapToTmp(String... args) {
    String tmpDir = System.getProperty("java.io.tmpdir");
    if (StringUtils.isBlank(tmpDir)) {
        tmpDir = "/tmp/";
    }
    String fileName = tmpDir + File.pathSeparatorChar + "dump";
    for (String arg : args) {
        fileName += "_" + arg;
    }
    fileName += "_" + System.nanoTime() + ".hprof";
    dumpHeap(fileName, true);
}

From source file:org.jenkinsci.plugins.durabletask.BourneShellScriptTest.java

@BeforeClass
public static void unixAndDocker() throws Exception {
    assumeTrue("This test is only for Unix", File.pathSeparatorChar == ':');
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    assumeThat("`docker version` could be run",
            new Launcher.LocalLauncher(StreamTaskListener.fromStderr()).launch()
                    .cmds("docker", "version", "--format", "{{.Client.Version}}")
                    .stdout(new TeeOutputStream(baos, System.err)).stderr(System.err).join(),
            is(0));// ww  w  .  jav a  2  s  . c o  m
    assumeThat("Docker must be at least 1.13.0 for this test (uses --init)",
            new VersionNumber(baos.toString().trim()), greaterThanOrEqualTo(new VersionNumber("1.13.0")));
}

From source file:net.sourceforge.vulcan.ant.JavaCommandBuilder.java

public String[] construct() {
    final List<String> args = new ArrayList<String>();

    args.add(javaExecutablePath);//from w  w w .ja v a 2 s.  co  m

    if (maxMemoryInMegabytes > 0) {
        args.add("-Xmx" + maxMemoryInMegabytes + "M");
    }

    if (!classPath.isEmpty()) {
        args.add("-classpath");
        args.add(StringUtils.join(classPath.iterator(), File.pathSeparatorChar));
    }

    for (String property : systemProperties.keySet()) {
        final StringBuffer arg = new StringBuffer("-D");
        arg.append(property);
        arg.append("=");
        arg.append(systemProperties.get(property));

        args.add(arg.toString());
    }

    args.add(mainClassName);

    for (String arg : arguments) {
        args.add(arg);
    }

    return args.toArray(new String[args.size()]);
}

From source file:org.gitools.ui.app.batch.tools.LoadTool.java

private String convertToFullPath(String file) {

    if (Strings.isNullOrEmpty(file)) {
        return file;
    }//from  w  ww. j a  v a2  s .  com

    file = file.trim();

    if (file.charAt(0) == File.pathSeparatorChar) {
        return file;
    }

    if (file.contains("://")) {
        return file;
    }

    String basePath = System.getProperty("user.dir");

    return FilenameUtils.concat(basePath, file);
}

From source file:net.sourceforge.vulcan.util.JavaCommandBuilder.java

public String[] construct() {
    final List<String> args = new ArrayList<String>();

    args.add(javaExecutablePath);/*from   w ww  .ja  va2  s  .  c om*/

    if (vmParameters != null) {
        Collections.addAll(args, vmParameters.split(" "));
    }

    if (!classPath.isEmpty()) {
        args.add("-classpath");
        args.add(StringUtils.join(classPath.iterator(), File.pathSeparatorChar));
    }

    for (String property : systemProperties.keySet()) {
        final StringBuilder arg = new StringBuilder("-D");
        arg.append(property);
        arg.append("=");
        arg.append(systemProperties.get(property));

        args.add(arg.toString());
    }

    args.add(mainClassName);

    for (String arg : arguments) {
        args.add(arg);
    }

    return args.toArray(new String[args.size()]);
}

From source file:com.thoughtworks.acceptance.SecurityManagerTest.java

protected void setUp() throws Exception {
    super.setUp();
    System.setSecurityManager(null);
    source = new CodeSource(new File("target").toURI().toURL(), (Certificate[]) null);

    sm = new DynamicSecurityManager();
    Policy policy = Policy.getPolicy();
    sm.setPermissions(source, policy.getPermissions(source));
    sm.addPermission(source, new RuntimePermission("setSecurityManager"));

    File mainClasses = new File(System.getProperty("user.dir"), "target/classes/-");
    File testClasses = new File(System.getProperty("user.dir"), "target/test-classes/-");
    String[] javaClassPath = StringUtils.split(System.getProperty("java.class.path"), File.pathSeparatorChar);
    File javaHome = new File(System.getProperty("java.home"), "-");

    // necessary permission start here
    sm.addPermission(source, new FilePermission(mainClasses.toString(), "read"));
    sm.addPermission(source, new FilePermission(testClasses.toString(), "read"));
    sm.addPermission(source, new FilePermission(javaHome.toString(), "read"));
    for (int i = 0; i < javaClassPath.length; ++i) {
        if (javaClassPath[i].endsWith(".jar")) {
            sm.addPermission(source, new FilePermission(javaClassPath[i], "read"));
        }/*from  w w w .  j  a va 2 s  . c  om*/
    }
}

From source file:org.codehaus.mojo.aspectj.AjcHelper.java

/**
 * Constructs AspectJ compiler classpath string
 * //  ww w  .  j ava2 s  .c o  m
 * @param project the Maven Project
 * @param pluginArtifacts the plugin Artifacts
 * @param outDirs the outputDirectories
 * @return a os spesific classpath string
 */
public static String createClassPath(MavenProject project, List pluginArtifacts, List outDirs) {
    String cp = new String();
    Set classPathElements = Collections.synchronizedSet(new LinkedHashSet());
    classPathElements.addAll(project.getDependencyArtifacts());
    classPathElements.addAll(project.getArtifacts());
    classPathElements.addAll(pluginArtifacts == null ? Collections.EMPTY_LIST : pluginArtifacts);
    Iterator iter = classPathElements.iterator();
    while (iter.hasNext()) {
        Artifact classPathElement = (Artifact) iter.next();
        File artifact = classPathElement.getFile();
        if (null != artifact) {
            cp += classPathElement.getFile().getAbsolutePath();
            cp += File.pathSeparatorChar;
        }
    }
    Iterator outIter = outDirs.iterator();
    while (outIter.hasNext()) {
        cp += outIter.next();
        cp += File.pathSeparatorChar;
    }

    if (cp.endsWith("" + File.pathSeparatorChar)) {
        cp = cp.substring(0, cp.length() - 1);
    }

    cp = StringUtils.replace(cp, "//", "/");
    return cp;
}

From source file:com.igormaznitsa.sciareto.preferences.FileHistoryManager.java

private FileHistoryManager() {
    final String projectsStr = PreferencesManager.getInstance().getPreferences().get(LAST_OPENED_PROJECTS,
            null);/* w w w  . j a  v  a  2s  .  co m*/
    final String filesStr = PreferencesManager.getInstance().getPreferences().get(LAST_OPENED_FILES, null);
    try {
        final String[] folders = projectsStr == null ? new String[0]
                : decodeString(projectsStr).split("\\" + File.pathSeparatorChar);
        final String[] files = filesStr == null ? new String[0]
                : decodeString(filesStr).split("\\" + File.pathSeparatorChar);
        fillList(folders, this.lastOpenedProjects);
        fillList(files, this.lastOpenedFiles);
    } catch (Exception ex) {
        throw new Error("Can't init module", ex);
    }
}

From source file:net.erdfelt.android.sdkfido.local.LocalAndroidPlatforms.java

/**
 * Attempt to find the local java sdk using the most common environment variables.
 * /*from   w ww  . j  a  v a 2  s . co  m*/
 * @return the local android java sdk directory
 * @throws IOException
 *             if unable to load the default local java sdk
 */
public static File findLocalJavaSdk() throws IOException {
    StringBuilder err = new StringBuilder();
    err.append("Unable to find the Local Android Java SDK Folder.");

    // Check Environment Variables First
    String envKeys[] = { "ANDROID_HOME", "ANDROID_SDK_ROOT" };
    for (String envKey : envKeys) {
        File sdkHome = getEnvironmentVariableDir(err, envKey);
        if (sdkHome == null) {
            continue; // skip, not found on that key
        }
        LocalAndroidPlatforms platforms = new LocalAndroidPlatforms(sdkHome);
        if (platforms.valid()) {
            return sdkHome;
        }
    }

    // Check Path for possible android.exe (or similar)
    List<String> searchBins = new ArrayList<String>();
    if (SystemUtils.IS_OS_WINDOWS) {
        searchBins.add("adb.exe");
        searchBins.add("emulator.exe");
        searchBins.add("android.exe");
    } else {
        searchBins.add("adb");
        searchBins.add("emulator");
        searchBins.add("android");
    }

    String pathParts[] = StringUtils.split(System.getenv("PATH"), File.pathSeparatorChar);
    for (String searchBin : searchBins) {
        err.append("\nSearched PATH for ").append(searchBin);
        for (String pathPart : pathParts) {
            File pathDir = new File(pathPart);
            LOG.fine("Searching Path: " + pathDir);
            File bin = new File(pathDir, searchBin);
            if (bin.exists() && bin.isFile() && bin.canExecute()) {
                File homeDir = bin.getParentFile().getParentFile();
                LOG.fine("Possible Home Dir: " + homeDir);
                LocalAndroidPlatforms platforms = new LocalAndroidPlatforms(homeDir);
                if (platforms.valid) {
                    return homeDir;
                }
            }
        }
        err.append(", not found.");
    }

    throw new FileNotFoundException(err.toString());
}