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.maven.plugin.cxx.utils.ExecutorService.java

public static CommandLine getExecutablePath(String executableName, Properties enviro, File dir) {
    File execFile = new File(executableName);
    String exec = null;// w w  w.  j a v a 2  s.c  o m
    if (execFile.exists() && execFile.isFile() && execFile.canExecute()) {
        //getLog().debug( "Toolchains are ignored, 'executable' parameter is set to " + execFile.getAbsolutePath() );
        exec = execFile.getAbsolutePath();
    } else {
        if (OS.isFamilyWindows()) {
            String ex = executableName.indexOf(".") < 0 ? executableName + ".bat" : executableName;
            File f = new File(dir, ex);
            if (f.exists()) {
                exec = ex;
            } else {
                // now try to figure the path from PATH, PATHEXT env vars
                // if bat file, wrap in cmd /c
                String path = (String) enviro.get("PATH");
                if (path != null) {
                    String[] elems = StringUtils.split(path, File.pathSeparator);
                    for (int i = 0; i < elems.length; i++) {
                        f = new File(new File(elems[i]), ex);
                        if (f.exists()) {
                            exec = ex;
                            break;
                        }
                    }
                }
            }
        }
    }

    if (exec == null) {
        exec = executableName;
    }

    CommandLine toRet;
    if (OS.isFamilyWindows() && exec.toLowerCase(Locale.getDefault()).endsWith(".bat")) {
        toRet = new CommandLine("cmd");
        toRet.addArgument("/c");
        toRet.addArgument(exec);
    } else {
        toRet = new CommandLine(exec);
    }

    return toRet;
}

From source file:net.grinder.util.GrinderClassPathUtils.java

/**
 * Construct the classpath of ngrinder which is very important and located in the head of
 * classpath./*w w  w.  j  a v a 2s  .c om*/
 * 
 * @param classPath
 *            classpath string
 * @param logger
 *            logger
 * @return classpath optimized for grinder.
 */
public static String filterForeMostClassPath(String classPath, Logger logger) {
    List<String> classPathList = new ArrayList<String>();
    for (String eachClassPath : checkNotNull(classPath).split(File.pathSeparator)) {
        String filename = FilenameUtils.getName(eachClassPath);
        if (isForeMostJar(filename)) {
            logger.trace("classpath :" + eachClassPath);
            classPathList.add(eachClassPath);
        }
    }
    return StringUtils.join(classPathList, File.pathSeparator);
}

From source file:org.apache.geode.test.compiler.JavaCompiler.java

public void addToClasspath(File jarFile) {
    classpath += File.pathSeparator + jarFile.getAbsolutePath();
}

From source file:no.kantega.publishing.spring.PluginStaticContentController.java

public PluginStaticContentController() {
    final String resourceBases = System.getProperty("resourceBases");

    // For easy development reload of plugin resources

    List<File> baseDirectories = new ArrayList<File>();

    if (resourceBases != null) {
        for (String base : resourceBases.split(File.pathSeparator)) {
            File baseFile = new File(base);
            if (baseFile.exists() && baseFile.isDirectory()) {
                baseDirectories.add(baseFile);
            }/*  ww w.ja v  a  2 s . c o  m*/
        }
    }

    this.baseDirectories = baseDirectories.toArray(new File[baseDirectories.size()]);

}

From source file:org.ebayopensource.turmeric.eclipse.test.utils.WsdlUtilTest.java

/**
 * @throws java.lang.Exception//from  www.j  a va2 s .  co  m
 */
@Override
@Before
public void setUpBeforeClass() throws Exception {

    String testDataLocation = getPluginOSPath(SoaTestConstants.PLUGIN_ID, SoaTestConstants.TEST_DATA)
            + File.pathSeparator + AbstractTestCase.class.getName();
    outputFile = new File(testDataLocation, "output");
    FileUtils.forceMkdir(outputFile);
    inputFile = new File(testDataLocation, "input");
    Assert.assertNotNull(inputFile);
}

From source file:org.apache.storm.localizer.LocallyCachedTopologyBlob.java

private static String resourcesJar() throws IOException {
    String path = ServerUtils.currentClasspath();
    if (path == null) {
        return null;
    }/*from   w w w. ja v a 2s .  c  o  m*/

    for (String jpath : path.split(File.pathSeparator)) {
        if (jpath.endsWith(".jar")) {
            if (ServerUtils.zipDoesContainDir(jpath, ServerConfigUtils.RESOURCES_SUBDIR)) {
                return jpath;
            }
        }
    }
    return null;
}

From source file:org.apache.hadoop.yarn.util.ApplicationClassLoader.java

@VisibleForTesting
static URL[] constructUrlsFromClasspath(String classpath) throws MalformedURLException {
    List<URL> urls = new ArrayList<URL>();
    for (String element : Splitter.on(File.pathSeparator).split(classpath)) {
        if (element.endsWith("/*")) {
            String dir = element.substring(0, element.length() - 1);
            File[] files = new File(dir).listFiles(JAR_FILENAME_FILTER);
            if (files != null) {
                for (File file : files) {
                    urls.add(file.toURI().toURL());
                }/*from w w  w  .  java 2 s .  co  m*/
            }
        } else {
            File file = new File(element);
            if (file.exists()) {
                urls.add(new File(element).toURI().toURL());
            }
        }
    }
    return urls.toArray(new URL[urls.size()]);
}

From source file:it.polimi.diceH2020.launcher.FileService.java

public Stream<Path> getBaseSolutionsPath() {
    String strDir = settings.getSolInstanceDir();
    Path dir = FileSystems.getDefault().getPath(strDir);
    if (Files.notExists(dir)) {
        Path currentRelativePath = Paths.get("");
        dir = FileSystems.getDefault()
                .getPath(currentRelativePath.toAbsolutePath().toString() + File.pathSeparator + strDir);
    }//from   ww w .  j a v  a  2 s  .  co m
    DirectoryStream<Path> stream;
    try {
        stream = Files.newDirectoryStream(dir, "*.{json}");
        return StreamSupport.stream(stream.spliterator(), false);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        return null;
    }
}

From source file:org.evosuite.executionmode.Continuous.java

public static Object execute(Options options, List<String> javaOpts, CommandLine line) {

    String opt = line.getOptionValue(NAME);
    if (opt == null) {
        LoggingUtils.getEvoLogger()/*  w  ww  .j a v a  2s  .  c  o  m*/
                .error("Missing option for -" + NAME + ". Use any of " + Arrays.toString(Command.values()));
        return null;
    }

    Command command = null;
    try {
        command = Command.valueOf(opt.toUpperCase());
    } catch (Exception e) {
        LoggingUtils.getEvoLogger()
                .error("Invalid option: " + opt + ". Use any of " + Arrays.toString(Command.values()));
        return null;
    }

    String target = null;

    //we need to define 'target' only for execute mode
    if (line.hasOption("target") && command.equals(Command.EXECUTE)) {
        target = line.getOptionValue("target");
    }

    String cp = ClassPathHandler.getInstance().getTargetProjectClasspath();

    /*
     * Setup the classpath
     */
    for (String classPathElement : cp.split(File.pathSeparator)) {
        try {
            ClassPathHacker.addFile(classPathElement);
        } catch (IOException e) {
            // Ignore?
        }
    }

    String prefix = "";
    if (line.hasOption("prefix")) {
        prefix = line.getOptionValue("prefix");
    }

    String[] cuts = null;
    if (Properties.CTG_SELECTED_CUTS != null && !Properties.CTG_SELECTED_CUTS.isEmpty()) {
        cuts = Properties.CTG_SELECTED_CUTS.trim().split(",");
    } else if (Properties.CTG_SELECTED_CUTS_FILE_LOCATION != null
            && !Properties.CTG_SELECTED_CUTS_FILE_LOCATION.isEmpty()) {
        File file = new File(Properties.CTG_SELECTED_CUTS_FILE_LOCATION);
        if (file.exists()) {
            String cutLine = null;
            try (InputStream in = new BufferedInputStream(new FileInputStream(file))) {
                Scanner scanner = new Scanner(in);
                cutLine = scanner.nextLine();
            } catch (Exception e) {
                LoggingUtils.getEvoLogger()
                        .error("Error while processing " + file.getAbsolutePath() + " : " + e.getMessage());
            }
            if (cutLine != null) {
                cuts = cutLine.trim().split(",");
            }
        }
    }

    ContinuousTestGeneration ctg = new ContinuousTestGeneration(target, cp, prefix,
            CtgConfiguration.getFromParameters(), cuts, Properties.CTG_EXPORT_FOLDER);

    /*
     * Based on command line option, execute one of the different CTG command
     */
    if (command.equals(Command.EXECUTE)) {

        if (Properties.SPAWN_PROCESS_MANAGER_PORT == null) {
            //CTG can be very risky to keep running without a spawn process manager
            int port = SpawnProcessKeepAliveChecker.getInstance().startServer();
            Properties.SPAWN_PROCESS_MANAGER_PORT = port;
        }

        String result = ctg.execute();
        LoggingUtils.getEvoLogger().info(result);
    } else if (command.equals(Command.CLEAN)) {
        boolean cleaned = ctg.clean();
        if (cleaned) {
            LoggingUtils.getEvoLogger().info("Cleaned all project data");
        } else {
            LoggingUtils.getEvoLogger().info("Failed to clean project");
        }
    } else { //INFO
        String info = ctg.info();
        LoggingUtils.getEvoLogger().info(info);
    }

    return null;
}