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:com.alvermont.terraj.fracplanet.io.JarLibraryLoader.java

/**
 * Adds our extraction path to the system library path.
 *
 * @throws NoSuchFieldException if there is a reflection error
 * @throws IllegalAccessException if there is an access error during reflection
 *//*from w  ww. j  a  v  a  2  s .  co m*/
public static void setupPath() throws NoSuchFieldException, IllegalAccessException {
    String dir = System.getProperty("user.home");

    dir = new File(dir).getPath();

    String newLibPath = dir + File.pathSeparator + System.getProperty("java.library.path");
    System.setProperty("java.library.path", newLibPath);

    Field fieldSysPath = ClassLoader.class.getDeclaredField("sys_paths");
    fieldSysPath.setAccessible(true);
    if (fieldSysPath != null) {
        fieldSysPath.set(System.class.getClassLoader(), null);
    }

    log.debug("Lib path: " + newLibPath);
}

From source file:averroes.options.AverroesOptions.java

/**
 * The list of application packages or classes separated by
 * {@link File#pathSeparator}.// w  w  w  . j  av  a  2 s  .c om
 * 
 * @return
 */
public static List<String> getApplicationRegex() {
    return Arrays.asList(cmd.getOptionValue(applicationRegex.getOpt()).split(File.pathSeparator));
}

From source file:com.orange.analysis.anasoot.main.AndroidPhase.java

/**
 * Run the analysis on a given SWF application
 * @param fileName the name of the application.
 * @param file The corresponding file/*from   w w  w. jav a  2s  . com*/
 * @param anaRule a set of rules for the check.
 * @param outStream the stream to print the result to.
 * @return 
 * @throws Alert if a problem is encountered during the analysis.
 */
public Map<String, JavaReport> runSoot(APKDescr apk, RuleFile ruleFile, HashSet<String> restriction,
        HashSet<String> notImplemented, PrintStream outStream) throws Alert {
    anasootconfig.readProperties();
    String classpath = config.androidClasspath() + File.pathSeparator + config.getTempDir();
    // Out.getMain().println(classpath);

    // String ondemand_pointsto = (anasootconfig.ondemandAnalysis) ? "true" : "false";
    String pointsto_options = "enabled:true"; // + enhanced_pointsto;
    // + ",cs-demand:"+ ondemand_pointsto;
    String sootArgs[] = { "--app", "-w", "-cp", classpath, // "-j2me", 
            "-main-class", WRAPPER_PATH, "-f", "n", "-keep-offset", "-p", "cg.spark", pointsto_options,
            "-dynamic-class", "java.lang.Object",
            // We explicitly deselect library packages and do not let soot choose for us.
            /*
            "-include-all","-x","javax.","-x","java.","-x","org.w3c.",
            "-x","org.xml.","-x","org.apache.commons.",
            "-x","com.francetelecom.rd.fakeandroid.","-x","android.",
            */
            "-x", "",
            // "-x","com.android.",
            "-d", androidOutput, WRAPPER_PATH };
    // Global Soot reset
    G.reset();
    G.v().out = Out.getLog();
    // Lancement des phases
    // Install the new transform.
    DevirtShow analysisPhase = new DevirtShow(outStream, anasootconfig, null, apk);
    Transform t1 = new Transform(AnasootPhase.ANALYSIS_PHASE + "." + AnasootPhase.ANALYSIS_TRANSFORM,
            analysisPhase);
    Transform t2 = new Transform(AnasootPhase.ANALYSIS_PHASE + "." + AnasootPhase.LOOP_TRANSFORM,
            new LoopTransform(outStream, ruleFile));
    PackManager pm = PackManager.v();
    pm.getPack(AnasootPhase.ANALYSIS_PHASE).add(t1);
    pm.getPack(AnasootPhase.ANALYSIS_PHASE).add(t2);

    // Register all the options in soot engine. 
    Options.v().parse(sootArgs);

    Scene scene = Scene.v();
    scene.setPhantomRefs(true);
    try {
        scene.loadBasicClasses();
        apk.getCode();
        AndroidWrapper wrapper = new AndroidWrapper(config, apk, restriction);
        wrapper.createWrapper();
        scene.loadBasicClasses();
        scene.loadClassAndSupport(WRAPPER_PATH);
        scene.loadDynamicClasses();
        scene.setDoneResolving();

    } catch (Exception e) {
        e.printStackTrace(Out.getLog());
        throw Alert.raised(e, "Cannot load the required classes. ");
    }

    AnaDroidRule androidRules = null;
    try {
        androidRules = new AnaDroidRule(ruleFile, "android2.1", anasootconfig);
        analysisPhase.setRuleFile(androidRules);
    } catch (IOException e) {
        e.printStackTrace(Out.getLog());
        throw Alert.raised(e, "Problem with rules.");
    }
    scoreReport = androidRules.getGlobal().getScore();
    updatePermissionScore(apk);
    // Initialize the scene with right classes + support for undefined ones.

    try {
        pm.getPack(AnasootPhase.POINTSTO_PHASE).apply();
        pm.getPack(AnasootPhase.ANALYSIS_PHASE).apply();
    } catch (AlertRuntimeException e) {
        AlertRuntimeException.unwrap(e);
    }

    return androidRules.getGlobal().getReports();
}

From source file:io.wcm.maven.plugins.nodejs.mojo.Task.java

private void setNodePath(ProcessBuilder pbuilder, NodeInstallationInformation information) {
    final Map<String, String> environment = pbuilder.environment();
    String pathVariableName = PATH_VARIABLE_NAME;
    String pathValue = environment.get(pathVariableName);
    if (Os.isFamily(Os.FAMILY_WINDOWS) || Os.isFamily(Os.FAMILY_WIN9X)) {
        for (String key : environment.keySet()) {
            if (PATH_VARIABLE_NAME.equalsIgnoreCase(key)) {
                pathVariableName = key;// w w w  .ja  va  2  s  .  c  o  m
                pathValue = environment.get(key);
            }
        }
    }
    if (pathValue == null) {
        environment.put(pathVariableName, information.getNodeExecutable().getParent());
    } else {
        environment.put(pathVariableName,
                information.getNodeExecutable().getParent() + File.pathSeparator + pathValue);
    }
}

From source file:com.asakusafw.runtime.util.hadoop.ConfigurationProviderTest.java

/**
 * search for hadoop command from PATH./*w w  w. ja va  2s.c  o  m*/
 */
@Test
public void findHadoopCommand_manypath() {
    putExec("path1/java");
    putExec("path2/hadoop");
    putExec("path3/ant");

    StringBuilder buf = new StringBuilder();
    buf.append(File.pathSeparator);
    buf.append(new File(folder.getRoot(), "path1").getAbsolutePath());
    buf.append(File.pathSeparator);
    buf.append(new File(folder.getRoot(), "path2").getAbsolutePath());
    buf.append(File.pathSeparator);
    buf.append(new File(folder.getRoot(), "path3").getAbsolutePath());
    buf.append(File.pathSeparator);

    Map<String, String> envp = new HashMap<>();
    envp.put("PATH", buf.toString());

    File file = ConfigurationProvider.findHadoopCommand(envp);
    assertThat(file, is(notNullValue()));
    assertThat(file.toString(), file.canExecute(), is(true));
    assertThat(file.toString(), file.getParentFile().getName(), is("path2"));
}

From source file:com.qwazr.compiler.JavaCompiler.java

private final static String buildClassPath(File[] classPathArray, Collection<URL> urlCollection)
        throws MalformedURLException, URISyntaxException {
    final List<String> classPathes = new ArrayList<>();

    URLClassLoader classLoader = (URLClassLoader) URLClassLoader.getSystemClassLoader();
    if (classLoader != null && classLoader.getURLs() != null) {
        for (URL url : classLoader.getURLs()) {
            String path = new File(url.toURI()).getAbsolutePath();
            classPathes.add(path);// w  w  w.j a  v a  2 s .com
            urlCollection.add(url);
        }
    }

    if (classPathArray != null) {
        for (File classPathFile : classPathArray) {
            if (classPathFile.isDirectory()) {
                for (File f : classPathFile.listFiles((FileFilter) FileFileFilter.FILE)) {
                    classPathes.add(f.getAbsolutePath());
                    urlCollection.add(f.toURI().toURL());
                }
            } else if (classPathFile.isFile()) {
                classPathes.add(classPathFile.getAbsolutePath());
                urlCollection.add(classPathFile.toURI().toURL());
            }
        }
    }
    if (classPathes.isEmpty())
        return null;
    return StringUtils.join(classPathes, File.pathSeparator);
}

From source file:org.jboss.arquillian.drone.webdriver.utils.Validate.java

private static void addPathFromEnvironment(final List<String> pathSegmentBuilder) {
    String pathName = "PATH";
    Map<String, String> env = System.getenv();
    if (!env.containsKey(pathName)) {
        for (String key : env.keySet()) {
            if (pathName.equalsIgnoreCase(key)) {
                pathName = key;/*from   w  w  w .j  av a2 s .c om*/
                break;
            }
        }
    }
    String path = env.get(pathName);
    if (path != null) {
        pathSegmentBuilder.addAll(Arrays.asList(path.split(File.pathSeparator)));
    }
}

From source file:com.l2jfree.lang.L2Thread.java

public static List<String> getStats() {
    List<String> list = new FastList<String>();

    list.add(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z").format(new Date()));
    list.add("");
    list.add("## Java Platform Information ##");
    list.add("Java Runtime Name: " + System.getProperty("java.runtime.name"));
    list.add("Java Version: " + System.getProperty("java.version"));
    list.add("Java Class Version: " + System.getProperty("java.class.version"));
    list.add("");
    list.add("## Virtual Machine Information ##");
    list.add("VM Name: " + System.getProperty("java.vm.name"));
    list.add("VM Version: " + System.getProperty("java.vm.version"));
    list.add("VM Vendor: " + System.getProperty("java.vm.vendor"));
    list.add("VM Info: " + System.getProperty("java.vm.info"));
    list.add("");
    list.add("## OS Information ##");
    list.add("Name: " + System.getProperty("os.name"));
    list.add("Architeture: " + System.getProperty("os.arch"));
    list.add("Version: " + System.getProperty("os.version"));
    list.add("");
    list.add("## Runtime Information ##");
    list.add("CPU Count: " + Runtime.getRuntime().availableProcessors());
    list.add("");
    for (String line : getMemoryUsageStatistics())
        list.add(line);//from  ww w . j av  a2 s.com
    list.add("");
    list.add("## Class Path Information ##\n");
    for (String lib : System.getProperty("java.class.path").split(File.pathSeparator))
        if (!list.contains(lib))
            list.add(lib);
    list.add("");

    Set<Thread> threads = new TreeSet<Thread>(new Comparator<Thread>() {
        @Override
        public int compare(Thread t1, Thread t2) {
            if (t1.isDaemon() != t2.isDaemon())
                return Boolean.valueOf(t1.isDaemon()).compareTo(t2.isDaemon());

            final StackTraceElement[] st1 = t1.getStackTrace();
            final StackTraceElement[] st2 = t2.getStackTrace();

            for (int i = 1;; i++) {
                final int i1 = st1.length - i;
                final int i2 = st2.length - i;

                if (i1 < 0 || i2 < 0)
                    break;

                final int compare = st1[i1].toString().compareToIgnoreCase(st2[i2].toString());

                if (compare != 0)
                    return compare;
            }

            if (st1.length != st2.length)
                return Integer.valueOf(st1.length).compareTo(st2.length);

            return Long.valueOf(t1.getId()).compareTo(t2.getId());
        }
    });
    threads.addAll(Thread.getAllStackTraces().keySet());
    list.add("## " + threads.size() + " thread(s) ##");
    list.add("=================================================");

    int i = 1;
    for (Thread thread : threads) {
        list.add("");
        list.add(i++ + ".");
        list.addAll(getStats(thread));
    }

    return list;
}

From source file:org.evosuite.junit.CoverageAnalysisOfProjectSystemTest.java

@Test
public void testMoreThanOneClassOneCriterion() throws IOException {
    createFakeProject();/*from   w w w . j  av a 2s.  c  o  m*/

    EvoSuite evosuite = new EvoSuite();

    Properties.CRITERION = new Properties.Criterion[] { Properties.Criterion.LINE };
    Properties.STATISTICS_BACKEND = StatisticsBackend.CSV;

    String[] command = new String[] { "-target", this.classes_directory.getAbsolutePath(),
            "-Djunit=" + this.tests_directory.getAbsolutePath(), "-projectCP",
            this.classes_directory.getAbsolutePath() + File.pathSeparator
                    + this.tests_directory.getAbsolutePath(),
            "-measureCoverage" };

    SearchStatistics statistics = (SearchStatistics) evosuite.parseCommandLine(command);
    Assert.assertNotNull(statistics);

    String statistics_file = System.getProperty("user.dir") + File.separator + Properties.REPORT_DIR
            + File.separator + "statistics.csv";

    CSVReader reader = new CSVReader(new FileReader(statistics_file));
    List<String[]> rows = reader.readAll();
    assertEquals(8, rows.size()); // header + 7 classes
    reader.close();

    // assert TargetClasses
    List<String> classes = CsvJUnitData.getValues(rows, "TARGET_CLASS");
    assertTrue(classes.contains(Calculator.class.getCanonicalName()));
    assertTrue(classes.contains(MethodWithSeveralInputArguments.class.getCanonicalName()));
    assertTrue(classes.contains(WordUtils.class.getCanonicalName()));
    assertTrue(classes.contains(FinalClass.class.getCanonicalName()));
    assertTrue(classes.contains(StringUtils.class.getCanonicalName()));
    assertTrue(classes.contains(ClassNumberUtils.class.getCanonicalName()));
    assertTrue(classes.contains(ClassWithPrivateInterfaces.class.getCanonicalName()));

    // assert Coverage
    List<String> coverages = CsvJUnitData.getValues(rows, "Coverage");
    assertTrue(coverages.size() == 7);
    Collections.sort(coverages);
    assertEquals(0.80, Double.valueOf(coverages.get(0)), 0.01);
    assertEquals(0.80, Double.valueOf(coverages.get(1)), 0.00);
    assertEquals(0.90, Double.valueOf(coverages.get(2)), 0.00);
    assertEquals(0.93, Double.valueOf(coverages.get(3)), 0.01);
    assertEquals(0.95, Double.valueOf(coverages.get(4)), 0.00);
    assertEquals(1.00, Double.valueOf(coverages.get(5)), 0.00);
    assertEquals(1.00, Double.valueOf(coverages.get(6)), 0.00);
}

From source file:edu.duke.cabig.c3pr.ant.UseCaseTraceabilityReport.java

private File buildClasspathFile() throws IOException, BuildException {
    File cpFile = File.createTempFile("uctrace-classpath-", "");
    FileWriter fw = new FileWriter(cpFile);
    logger.debug("Writing classpath to " + cpFile);
    fw.write("-cp\n");
    fw.write(Utils.join(buildClasspath().iterator(), File.pathSeparator));
    fw.close();/*from w w  w.  j  a  v a 2  s .  c  o m*/
    logger.debug("Finished writing test cases list");
    return cpFile;
}