Example usage for java.io File pathSeparator

List of usage examples for java.io File pathSeparator

Introduction

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

Prototype

String pathSeparator

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

Click Source Link

Document

The system-dependent path-separator character, represented as a string for convenience.

Usage

From source file:org.apache.hadoop.hdfs.server.namenode.AvatarNodeNew.java

public void copyEditLogToNFS(String NFSEditPath) throws IOException {
    String[] editsdir = this.startupConf.getStrings("dfs.name.edits.dir");
    String msg = "";

    FileSystem localFs = FileSystem.getLocal(this.confg).getRaw();

    File srcedit = new File(editsdir[0]);

    File destedit = new File(NFSEditPath);
    String mdate = dateForm.format(new Date(now()));

    // copy editlog directory if needed
    if (srcedit.exists()) {

        if (destedit.exists()) {
            File tmp = new File(destedit + File.pathSeparator + mdate);
            if (!destedit.renameTo(tmp)) {
                throw new IOException("Unable to rename " + destedit + " to " + tmp);
            }/*from w w  w . j ava2  s. c  o m*/
            LOG.info("Moved aside " + destedit + " as " + tmp);
        }

        if (!FileUtil.copy(localFs, new Path(srcedit.toString()), localFs, new Path(destedit.toString()), false,
                this.startupConf)) {
            msg = "Error copying " + srcedit + " to " + destedit;
            LOG.error(msg);
            throw new IOException(msg);
        }
        LOG.info("Copied " + srcedit + " into " + destedit);

    }
}

From source file:au.org.ala.delta.util.Utils.java

private static boolean launchIntkeyViaScript(String startupDirectory, String inputFile) {
    String scriptFile = (Platform.isWindows() ? "Intkey.bat" : "Intkey.sh");
    // The DELTA scripts set a System property "basedir" - this is more
    // reliable than the current directory
    // as if the script is on the path the current directory won't be the
    // script directory.
    if (StringUtils.isNotBlank(System.getProperty("basedir"))) {
        String scriptDir = System.getProperty("basedir") + File.separator + "bin" + File.separator + scriptFile;
        if (launchFile(scriptDir, inputFile)) {
            return true;
        }/*from  w w w  .  j a  va 2 s  .co m*/
    }
    String fullpath = String.format("%s%s%s", startupDirectory, File.separator, scriptFile);
    if (!launchFile(fullpath, inputFile)) {
        String path = System.getenv("PATH");
        String[] elements = path.split("\\Q" + File.pathSeparator + "\\E");
        for (String element : elements) {
            fullpath = String.format("%s%s%s", element, File.separator, scriptFile);
            if (launchFile(fullpath, inputFile)) {
                return true;
            }
        }
        return false;
    }
    return true;
}

From source file:au.org.ala.delta.util.Utils.java

private static void launchIntkeyViaClassLoader(String inputFile) throws Exception {
    // Gah.... this is a horrible work around for the fact that
    // the swing application framework relies on a static
    // Application instance so we can't have the Editor and
    // Intkey playing together nicely in the same JVM.
    // It doesn't really work properly anyway, the swing application
    // framework generates exceptions during loading and saving
    // state due to failing instanceof checks.
    String classPath = System.getProperty("java.class.path");
    String[] path = classPath.split(File.pathSeparator);
    List<URL> urls = new ArrayList<URL>();
    for (String pathEntry : path) {
        urls.add(new File(pathEntry).toURI().toURL());
    }/*from  w w w  . jav  a2s  . c om*/
    ClassLoader intkeyLoader = new URLClassLoader(urls.toArray(new URL[0]),
            ClassLoader.getSystemClassLoader().getParent());
    Class<?> intkey = intkeyLoader.loadClass("au.org.ala.delta.intkey.Intkey");
    Method main = intkey.getMethod("main", String[].class);
    main.invoke(null, (Object) new String[] { inputFile });
}

From source file:org.apache.storm.utils.Utils.java

/**
 * Get a map of version to classpath from the conf Config.SUPERVISOR_WORKER_VERSION_CLASSPATH_MAP
 * @param conf what to read it out of//from w ww. j a  v  a2 s. co  m
 * @param currentCP the current classpath for this version of storm (not included in the conf, but returned by this)
 * @return the map
 */
public static NavigableMap<SimpleVersion, List<String>> getConfiguredClasspathVersions(Map<String, Object> conf,
        List<String> currentCP) {
    TreeMap<SimpleVersion, List<String>> ret = new TreeMap<>();
    Map<String, String> fromConf = (Map<String, String>) conf
            .getOrDefault(Config.SUPERVISOR_WORKER_VERSION_CLASSPATH_MAP, Collections.emptyMap());
    for (Map.Entry<String, String> entry : fromConf.entrySet()) {
        ret.put(new SimpleVersion(entry.getKey()), Arrays.asList(entry.getValue().split(File.pathSeparator)));
    }
    ret.put(VersionInfo.OUR_VERSION, currentCP);
    return ret;
}

From source file:com.adito.agent.client.Agent.java

protected static AgentArgs initArgs(String[] args) throws Throwable {
    int shutdown = -1;
    int webforwardInactivity = 300000;
    int tunnelInactivity = 600000;

    AgentArgs agentArgs = new AgentArgs();
    AgentConfiguration configuration = new AgentConfiguration();

    String hostHeader = null;//from   w  w w.  j a  va  2s  .c  o  m
    String protocol = null;
    for (int i = 0; i < args.length; i++) {
        if (args[i].startsWith("host")) { //$NON-NLS-1$
            hostHeader = getCommandLineValue(args[i]);
        } else if (args[i].startsWith("protocol")) { //$NON-NLS-1$
            protocol = getCommandLineValue(args[i]);
        } else if (args[i].startsWith("username")) { //$NON-NLS-1$
            agentArgs.setUsername(getCommandLineValue(args[i]));
        } else if (args[i].startsWith("password")) { //$NON-NLS-1$
            agentArgs.setPassword(getCommandLineValue(args[i]));
        } else if (args[i].startsWith("localProxyURL")) { //$NON-NLS-1$
            agentArgs.setLocalProxyURL(getCommandLineValue(args[i]));
        } else if (args[i].startsWith("reverseProxyURL")) { //$NON-NLS-1$
            agentArgs.setReverseProxyURL(getCommandLineValue(args[i]));
        } else if (args[i].startsWith("pluginProxyURL")) { //$NON-NLS-1$
            agentArgs.setPluginProxyURL(getCommandLineValue(args[i]));
        } else if (args[i].startsWith("ticket")) { //$NON-NLS-1$
            agentArgs.setTicket(getCommandLineValue(args[i]));
        } else if (args[i].startsWith("browserCommand")) { //$NON-NLS-1$
            agentArgs.setBrowserCommand(getCommandLineValue(args[i]));
        } else if (args[i].startsWith("userAgent")) { //$NON-NLS-1$
            String userAgent = getCommandLineValue(args[i]);
            agentArgs.setUserAgent(userAgent);
            HttpClient.setUserAgent(userAgent);
        } else if (args[i].startsWith("locale")) { //$NON-NLS-1$
            agentArgs.setLocaleName(getCommandLineValue(args[i]));
        } else if (args[i].startsWith("disableNewSSLEngine")) { //$NON-NLS-1$
            agentArgs.setDisableNewSSLEngine(Boolean.valueOf(getCommandLineValue(args[i])).booleanValue());
        } else if (args[i].startsWith("webforward.inactivity")) { //$NON-NLS-1$
            try {
                webforwardInactivity = Integer.parseInt(getCommandLineValue(args[i]));
            } catch (NumberFormatException ex) {
            }
        } else if (args[i].startsWith("tunnel.inactivity")) { //$NON-NLS-1$
            try {
                tunnelInactivity = Integer.parseInt(getCommandLineValue(args[i]));
            } catch (NumberFormatException ex) {
            }
        } else if (args[i].startsWith("shutdown")) { //$NON-NLS-1$
            try {
                shutdown = Integer.parseInt(getCommandLineValue(args[i]));
            } catch (NumberFormatException ex) {
            }
        } else if (args[i].startsWith("log4j")) { //$NON-NLS-1$
            agentArgs.setLogProperties(getCommandLineValue(args[i]));
        } else if (args[i].startsWith("extensionClasses")) { //$NON-NLS-1$
            agentArgs.setExtensionClasses(getCommandLineValue(args[i]));
        } else if (args[i].startsWith("ignoreCertWarnings")) {
            System.getProperties().put("com.maverick.ssl.allowUntrustedCertificates", "true");
            System.getProperties().put("com.maverick.ssl.allowInvalidCertificates", "true");
        } else if (args[i].startsWith("forceBasicUI")) {
            configuration.setGUIClass("com.adito.agent.client.gui.BasicFrameGUI");
        } else if (args[i].startsWith("displayInformationPopups")) {
            configuration.setDisplayInformationPopups(getCommandLineValue(args[i]).equalsIgnoreCase("true"));
        } else if (args[i].startsWith("remoteTunnelsRequireConfirmation")) {
            configuration
                    .setRemoteTunnelsRequireConfirmation(getCommandLineValue(args[i]).equalsIgnoreCase("true"));
        } else if (args[i].startsWith("cleanOnExit")) {
            configuration.setCleanOnExit(getCommandLineValue(args[i]).equalsIgnoreCase("true"));
        } else if (args[i].startsWith("localhostAddress")) {
            configuration.setLocalhostAddress(getCommandLineValue(args[i]));
        } else if (args[i].startsWith("dir")) {
            configuration.setCacheDir(new File(Utils.getHomeDirectory(), getCommandLineValue(args[i])));
        } else if (args[i].startsWith("removeFiles")) {
            StringTokenizer files = new StringTokenizer(getCommandLineValue(args[i]), File.pathSeparator);
            while (files.hasMoreTokens()) {
                configuration.removeFileOnExit(new File(files.nextToken()));
            }
        } else if (args[i].startsWith("keepAlivePeriod")) {
            configuration.setKeepAlivePeriod(Integer.parseInt(getCommandLineValue(args[i])));
        } else if (args[i].startsWith("extensionId")) {
            agentArgs.setExtensionId(getCommandLineValue(args[i]));
        }
    }

    if (hostHeader == null || protocol == null) {
        throw new IOException("");
    } else {
        int idx = hostHeader.indexOf(':');
        if (idx > -1) {
            String port = hostHeader.substring(idx + 1);
            agentArgs.setHostname(hostHeader.substring(0, idx));
            try {
                agentArgs.setPort(Integer.parseInt(port));
            } catch (NumberFormatException ex) {
            }
            agentArgs.setSecure(protocol.equalsIgnoreCase("https"));
        } else {
            agentArgs.setHostname(hostHeader);
            agentArgs.setPort(protocol.equalsIgnoreCase("http") ? 80 : 443);
            agentArgs.setSecure(protocol.equalsIgnoreCase("https"));
        }
    }

    if (isWindows64()) {
        configuration.setGUIClass("com.adito.agent.client.gui.BasicFrameGUI");
    }

    WinRegistry.setLocation(new File(configuration.getCacheDir(),
            "applications" + File.separator + agentArgs.getExtensionId()));

    /*
     * Load the message resources.
     */
    Locale.setDefault(Utils.createLocale(agentArgs.getLocaleName()));

    if (agentArgs.getLogProperties() == null) {
        System.out.println(Messages.getString("VPNClient.main.debugModeWarning")); //$NON-NLS-1$
    }

    if (agentArgs.getPort() == -1 || agentArgs.getHostname() == null || agentArgs.getUsername() == null
            || (agentArgs.getTicket() == null && agentArgs.getPassword() == null))
        throw new IOException(Messages.getString("VPNClient.main.missingCommandLineArguments")); //$NON-NLS-1$

    if (shutdown > -1)
        configuration.setShutdownPeriod(shutdown);
    configuration.setSystemExitOnDisconnect(true);
    configuration.setWebForwardInactivity(webforwardInactivity);
    configuration.setTunnelInactivity(tunnelInactivity);

    agentArgs.setAgentConfiguration(configuration);
    return agentArgs;
}

From source file:org.hyperic.hq.bizapp.agent.client.AgentClient.java

/**
 * @param s A string that might contain unix-style classpath separators.
 * @return The correct path for this platform (i.e, if win32, replace : with ;).
 *///w  w w. j a  va2  s  .  c om
private static String normalizeClassPath(String s) {
    return StringUtil.replace(s, ":", File.pathSeparator);
}

From source file:ca.weblite.xmlvm.XMLVM.java

public void generateXMLVMCache(File src) {
    try {//from w w w.  j  ava 2s.  co  m
        System.out.println("Running XMLVM with input " + src);
        this.runXmlvm(new String[] { "--in=" + src.getAbsolutePath(),
                "--out=" + getXmlvmCacheDir("xmlvm").getAbsolutePath(), "--target=xmlvm",
                "--libraries=" + getJavac().getClasspath().toString().replaceAll(File.pathSeparator, ","),
                "--load-dependencies", "--disable-vtable-optimizations" });
    } catch (Exception ex) {
        Logger.getLogger(XMLVM.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:ca.weblite.xmlvm.XMLVM.java

private void doCompile() throws IOException {
    try {//from w  w w.j a  va  2 s  .  co m
        if (getJavac() == null) {
            setJavac((Javac) getProject().createTask("javac"));
        }

        // Create a temporary directory as a destination for javac 
        File tmpBuild = File.createTempFile("build", "build");
        tmpBuild.delete();
        tmpBuild.mkdir();

        // Create a temporary directory to contain only the .java files that
        // have changed.
        File changedSrcDir = setupChangedSourcesDir();

        getJavac().setDestdir(tmpBuild);

        getJavac().setSrcdir(new Path(getProject(), changedSrcDir.getAbsolutePath()));
        getJavac().setClasspath(getClassPath());
        getJavac().getClasspath().add(new Path(getProject(), getJavaBuildDir().getAbsolutePath()));
        getJavac().execute();

        // Copy the compiled files to the intermediate build dir
        Copy copy = (Copy) getProject().createTask("copy");
        copy.setTodir(getJavaBuildDir());
        FileSet fs = new FileSet();
        fs.setDir(tmpBuild);
        fs.setIncludes("**");
        copy.addFileset(fs);
        copy.setOverwrite(true);
        copy.execute();

        // Now generate .xmlvm files
        File tmpOutput = File.createTempFile("tmpOut", "dir");
        tmpOutput.delete();
        tmpOutput.mkdir();

        System.out.println(tmpBuild.list().length + " class files generated");

        File[] converted = this.classToXMLVM(tmpBuild, tmpOutput);

        System.out.println(converted.length + " xmlvm files generated");

        // Now look for dependencies in generated files.
        try {
            this.loadDependencies(tmpOutput, Arrays.asList(converted));

        } catch (Exception ex) {
            System.out.println("Generating XMLVM Cache...");
            this.generateXMLVMCache(tmpOutput);
        }

        try {
            this.loadDependencies(tmpOutput, Arrays.asList(converted));
        } catch (Exception ex) {
            System.out.println("First attempt at XMLVM Cache seemed to fail");
            System.out.println("Trying from the Java source");
            this.generateXMLVMCache(tmpBuild);
        }
        try {
            this.loadDependencies(tmpOutput, Arrays.asList(converted));
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }

        // Now we should have all we need to generate our C source files
        // Delete the changed source dir, since we don't need it anymore
        Delete del = (Delete) getProject().createTask("delete");
        del.setDir(changedSrcDir);
        del.execute();

        File intermediateOut = this.getXmlvmCacheDir("c");

        //System.out.println("Intermediates: ");
        //for ( File f : tmpOutput.listFiles()){
        //    System.out.println(f);
        //}

        System.out.println("Converting " + tmpOutput.list().length + " xmlvm files to " + getTarget()
                + " source files....");
        this.runXmlvm(new String[] { "--in=" + tmpOutput.getAbsolutePath(),
                "--out=" + intermediateOut.getAbsolutePath(), "--target=" + getTarget(),
                "--libraries=" + getJavac().getClasspath().toString().replaceAll(File.pathSeparator, ","),
                "--c-source-extension=m", //"--debug=all",
                "--disable-vtable-optimizations" });

        del = (Delete) getProject().createTask("delete");
        del.setDir(tmpBuild);
        del.execute();

        copyChangedSource(intermediateOut, getDest());

    } catch (Exception ex) {
        Logger.getLogger(XMLVM.class.getName()).log(Level.SEVERE, null, ex);
    }

}

From source file:com.google.dart.tools.core.DartCore.java

/**
 * Given an IProject, return the appropriate java.io.File representing a package root. This can be
 * null if a package root should not be used.
 * //from  ww  w. j a v a 2 s . c  om
 * @param project the IProject
 * @return the File for the package root, or null if none
 */
public File getPackageRoot(IProject project) {
    if (project != null) {
        String setting = getProjectPreferences(project).get(PROJECT_PREF_PACKAGE_ROOT, "");

        if (setting != null && setting.length() > 0) {
            String[] paths = setting.split(File.pathSeparator);
            return new File(paths[0]);
        }
    }

    File[] roots = CmdLineOptions.getOptions().getPackageRoots();

    if (roots.length > 0) {
        return roots[0];
    }

    return null;
}

From source file:org.ebayopensource.turmeric.tools.library.builders.CodeGenTypeLibraryGenerator.java

private static String populateClasspath(TypeLibraryCodeGenContext codeGenCtx) {
    StringBuilder sb = new StringBuilder();
    sb.append("-classpath").append(",");
    sb.append(codeGenCtx.getGenMetaSrcDestFolder()).append(",");
    sb.append("-classpath").append(",");
    sb.append(codeGenCtx.getMetaSrcFolder()).append(",");

    if (codeGenCtx != null) {
        String additionalClasPathFromPlugin = codeGenCtx.getTypeLibraryInputOptions()
                .getAdditionalClassPathToXJC();
        if (!TypeLibraryUtilities.isEmptyString(additionalClasPathFromPlugin)) {
            String classpaths[] = additionalClasPathFromPlugin.split(File.pathSeparator);
            for (String classPath : classpaths) {
                sb.append("-classpath").append(",").append(classPath).append(",");
                if (codeGenCtx.getTypeLibraryInputOptions().isAddBuildClassPathToXJC()) {
                    // This should not be added by default, it's not compatible with eclipse or maven
                    sb.append("-classpath").append(",");
                    sb.append(TypeLibraryUtilities.normalizePath(classPath));
                    sb.append("build").append(File.separatorChar);
                    sb.append("classes,");
                }//  ww  w .  jav  a2 s  .  c  om
            }
        }
    }

    return sb.toString();

}