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:Main.java

public static void main(String[] args) {

    System.out.println(File.pathSeparator);
}

From source file:org.coursera.courier.JavaGenerator.java

public static void main(String[] args) throws Throwable {
    if (args.length != 3) {
        throw new IllegalArgumentException("Usage: " + JavaGenerator.class.getName()
                + " targetPath resolverPath sourcePath1[:sourcePath2]+");
    }//from w  w  w. j  ava2  s . c om
    String targetPath = args[0];
    String resolverPath = args[1];
    String sourcePathString = args[2];
    String[] sourcePaths = sourcePathString.split(File.pathSeparator);

    GeneratorRunnerOptions options = new GeneratorRunnerOptions(targetPath, sourcePaths, resolverPath);

    new DefaultGeneratorRunner().run(new JavaGenerator(), options);
}

From source file:edu.ksu.cis.indus.xmlizer.JimpleXMLizerCLI.java

/**
 * The entry point to execute this xmlizer from command prompt.
 * /*from w w w. j a  va 2 s .  c o  m*/
 * @param s is the command-line arguments.
 * @throws RuntimeException when jimple xmlization fails.
 * @pre s != null
 */
public static void main(final String[] s) {
    final Scene _scene = Scene.v();

    final Options _options = new Options();
    Option _o = new Option("d", "dump directory", true, "The directory in which to write the xml files.  "
            + "If unspecified, the xml output will be directed standard out.");
    _o.setArgs(1);
    _o.setArgName("path");
    _o.setOptionalArg(false);
    _options.addOption(_o);
    _o = new Option("h", "help", false, "Display message.");
    _options.addOption(_o);
    _o = new Option("p", "soot-classpath", true, "Prepend this to soot class path.");
    _o.setArgs(1);
    _o.setArgName("classpath");
    _o.setOptionalArg(false);
    _options.addOption(_o);

    final HelpFormatter _help = new HelpFormatter();

    try {
        final CommandLine _cl = (new BasicParser()).parse(_options, s);
        final String[] _args = _cl.getArgs();

        if (_cl.hasOption('h')) {
            final String _cmdLineSyn = "java " + JimpleXMLizerCLI.class.getName() + "<options> <class names>";
            _help.printHelp(_cmdLineSyn.length(), _cmdLineSyn, "", _options, "", true);
        } else {
            if (_args.length > 0) {
                if (_cl.hasOption('p')) {
                    _scene.setSootClassPath(
                            _cl.getOptionValue('p') + File.pathSeparator + _scene.getSootClassPath());
                }

                final NamedTag _tag = new NamedTag("JimpleXMLizer");

                for (int _i = 0; _i < _args.length; _i++) {
                    final SootClass _sc = _scene.loadClassAndSupport(_args[_i]);
                    _sc.addTag(_tag);
                }
                final IProcessingFilter _filter = new TagBasedProcessingFilter(_tag.getName());
                writeJimpleAsXML(new Environment(_scene), _cl.getOptionValue('d'), null,
                        new UniqueJimpleIDGenerator(), _filter);
            } else {
                System.out.println("No classes were specified.");
            }
        }
    } catch (final ParseException _e) {
        LOGGER.error("Error while parsing command line.", _e);
        printUsage(_options);
    } catch (final Throwable _e) {
        LOGGER.error("Beyond our control. May day! May day!", _e);
        throw new RuntimeException(_e);
    }
}

From source file:org.kepler.Kepler.java

public static void main(String[] args) {

    //System.out.println("java.library.path = " + System.getProperty("java.library.path"));

    // log4j uses the first log4j.properties file found on the classpath. 
    // since kepler's classpath is complicated, it is not always obvious
    // which log4j.properties is used; it may be hidden in a jar file.
    // this prints the log4j.properties file found on the classpath.
    File log4jFile = FileUtilities.nameToFile("$CLASSPATH/log4j.properties", null);
    if (log4jFile == null) {
        System.out.println("log4j.properties not found in CLASSPATH.");
    } else {/*from ww  w  .  ja  va2 s .  co  m*/
        System.out.println("log4j.properties found in CLASSPATH: " + log4jFile);
    }

    // Save the args in case they are needed later.
    // long startTime = System.currentTimeMillis();
    _args = args;
    CommandLineArgs.store(args);
    List<String> argList = Arrays.asList(args);

    // parse the command line arguments
    if (!parseArgs(args)) {
        // an error occurred, so exit.
        return;
    }

    RepositoryLocations.setReleaseLocation(org.kepler.modulemanager.RepositoryLocations.getReleaseLocation());
    ModuleTree.init();

    // if we are executing a workflow from the command line, check now for
    // patches.
    if (_action == Action.RunKAR || _action == Action.RunWf) {
        // if we are running headless, do not display a dialog if patches
        // are available
        if (!_runWithGui || _displayRedirectOutputPath != null) {
            PatchChecker.check(true);
        } else {
            PatchChecker.check(false);
        }
        // show the splash if the Kepler UI is starting
    } else if (_action == Action.Kepler && _showSplash) {
        _showSplash();
    }

    System.gc();
    ShutdownNotifier.addShutdownListener(new Shutdown());
    try {
        setJavaPropertiesAndCopyModuleDirectories();

        // System.out.println("os: " + System.getProperty("os.name"));
        String OSName = System.getProperty("os.name");

        // Hashtable properties = getProject().getProperties();
        ModuleTree moduleTree = ModuleTree.instance();

        String classpath = System.getProperty("java.class.path");
        String[] classpathItems = classpath.split(File.pathSeparator);

        for (Module module : moduleTree) {

            // XXX since Module dir variables can be wrong, utilizing classpath
            // to determine module location on disk. Use below line instead when 
            // that's fixed.
            //File osextension = new File(module.getModuleInfoDir() + File.separator + "osextension.txt");
            File osextension = null;
            String sought = File.separator + module.getName() + File.separator;
            for (String path : classpathItems) {
                // must check each match since parent path could possibly have a module name
                // in it (don't break on first):
                if (path.contains(sought)) {
                    int lastIndex = path.lastIndexOf(sought);
                    String p = path.substring(0, lastIndex);
                    p = p.concat(sought + "module-info" + File.separator + "osextension.txt");
                    osextension = new File(p);
                    if (osextension.exists()) {
                        break;
                    }
                }
            }
            if (osextension == null || !osextension.exists()) {
                continue;
            }

            System.out.println("Found OS Extension file: " + osextension.getAbsolutePath());
            Hashtable<String, String> properties = readOSExtensionFile(osextension);
            Enumeration<String> keys = properties.keys();
            while (keys.hasMoreElements()) {
                String extClass = keys.nextElement();
                String os = properties.get(extClass);
                if (OSName.trim().equals(os.trim())) {
                    // if we're in an OS that an extension
                    // needs to be loaded for attempt to load
                    // the OSExtension via reflection
                    // and run the addOSExtension method

                    Class<?> c = Class.forName(extClass);
                    try {
                        OSExtension extension = (OSExtension) c.newInstance();
                        extension.addOSExtensions();
                        System.out.println("loading OS extensions for OS " + os + " with class " + extClass);
                    } catch (ClassCastException cce) {
                        // System.out.println(extClass +
                        // " is not an instance of OSExtension");
                    }
                }
            }
        }

        Project project = new Project();
        File projDir = ProjectLocator.getProjectDir();
        project.setBaseDir(projDir);
        setOntologyIndexFile();

        if (!argList.contains("-runwf")) {
            // Allow developers to turn off MakeKars by creating
            // a file called "skipMakeKars" in the project root
            File skipMakeKars = new File(projDir, "skipMakeKars");
            if (!skipMakeKars.exists()) {
                MakeKars kar = new MakeKars();
                kar.setProject(project);
                kar.init();
                kar.run();
            }
        }

        PermissionManager.makeNativeLibsExecutable();
        // CreateIntroFileTask createIntroFileTask = new
        // CreateIntroFileTask();
        // createIntroFileTask.execute();

    } catch (URISyntaxException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }

    runApplication();
    // System.exit(0);

    // long endTime = System.currentTimeMillis();
    // System.out.println( (endTime-startTime)/1000.0 );
}

From source file:org.apache.jorphan.test.AllTests.java

/**
 * Starts a run through all unit tests found in the specified classpaths.
 * The first argument should be a list of paths to search. The second
 * argument is optional and specifies a properties file used to initialize
 * logging. The third argument is also optional, and specifies a class that
 * implements the UnitTestManager interface. This provides a means of
 * initializing your application with a configuration file prior to the
 * start of any unit tests.//  w  ww .  j av a 2 s . co m
 * 
 * @param args
 *            the command line arguments
 */
public static void main(String[] args) {
    if (args.length < 1) {
        System.out.println("You must specify a comma-delimited list of paths to search " + "for unit tests");
        return;
    }
    String home = new File(System.getProperty("user.dir")).getParent();
    System.out.println("Setting JMeterHome: " + home);
    JMeterUtils.setJMeterHome(home);
    initializeLogging(args);
    initializeManager(args);

    String version = "JMeterVersion=" + JMeterUtils.getJMeterVersion();
    log.info(version);
    System.out.println(version);
    logprop("java.version", true);
    logprop("java.vm.name");
    logprop("java.vendor");
    logprop("java.home", true);
    logprop("file.encoding", true);
    // Display actual encoding used (will differ if file.encoding is not recognised)
    String msg = "default encoding=" + Charset.defaultCharset();
    System.out.println(msg);
    log.info(msg);
    logprop("user.home");
    logprop("user.dir", true);
    logprop("user.language");
    logprop("user.region");
    logprop("user.country");
    logprop("user.variant");
    final String showLocale = "Locale=" + Locale.getDefault().toString();
    log.info(showLocale);
    System.out.println(showLocale);
    logprop("os.name", true);
    logprop("os.version", true);
    logprop("os.arch");
    logprop("java.class.version");
    // logprop("java.class.path");
    String cp = System.getProperty("java.class.path");
    String cpe[] = JOrphanUtils.split(cp, java.io.File.pathSeparator);
    StringBuilder sb = new StringBuilder(3000);
    sb.append("java.class.path=");
    for (int i = 0; i < cpe.length; i++) {
        sb.append("\n");
        sb.append(cpe[i]);
        if (new java.io.File(cpe[i]).exists()) {
            sb.append(" - OK");
        } else {
            sb.append(" - ??");
        }
    }
    log.info(sb.toString());

    // ++
    // GUI tests throw the error
    // testArgumentCreation(org.apache.jmeter.config.gui.ArgumentsPanel$Test)java.lang.NoClassDefFoundError
    // at java.lang.Class.forName0(Native Method)
    // at java.lang.Class.forName(Class.java:141)
    // at
    // java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:62)
    //
    // Try to find out why this is ...

    System.out.println("+++++++++++");
    logprop("java.awt.headless", true);
    logprop("java.awt.graphicsenv", true);
    //
    // try {//
    // Class c = Class.forName(n);
    // System.out.println("Found class: "+n);
    // // c.newInstance();
    // // System.out.println("Instantiated: "+n);
    // } catch (Exception e1) {
    // System.out.println("Error finding class "+n+" "+e1);
    // } catch (java.lang.InternalError e1){
    // System.out.println("Error finding class "+n+" "+e1);
    // }
    //
    System.out.println("------------");
    // don't call isHeadless() here, as it has a side effect.
    // --
    System.out.println("Creating test suite");
    TestSuite suite = suite(args[0]);
    int countTestCases = suite.countTestCases();
    System.out.println("Starting test run, test count = " + countTestCases);
    //        for (int i=0;i<suite.testCount();i++){
    //           Test testAt = suite.testAt(i);
    //           int testCases = testAt.countTestCases();
    //           if (testAt instanceof junit.framework.TestCase){
    //                System.out.print(((junit.framework.TestCase) testAt).getName());
    //            }
    //            if (testAt instanceof TestSuite){
    //                TestSuite testSuite = ((TestSuite) testAt);
    //                String name = testSuite.getName();
    //                System.out.print(name);
    //                System.out.println(" "+testCases);
    //            }                
    //        }

    // Jeremy Arnold: This method used to attempt to write results to
    // a file, but it had a bug and instead just wrote to System.out.
    // Since nobody has complained about this behavior, I'm changing
    // the code to not attempt to write to a file, so it will continue
    // behaving as it did before. It would be simple to make it write
    // to a file instead if that is the desired behavior.
    TestResult result = TestRunner.run(suite);
    // ++
    // Recheck settings:
    //System.out.println("+++++++++++");
    // System.out.println(e+"="+System.getProperty(e));
    // System.out.println(g+"="+System.getProperty(g));
    // System.out.println("Headless?
    // "+java.awt.GraphicsEnvironment.isHeadless());
    // try {
    // Class c = Class.forName(n);
    // System.out.println("Found class: "+n);
    // c.newInstance();
    // System.out.println("Instantiated: "+n);
    // } catch (Exception e1) {
    // System.out.println("Error with class "+n+" "+e1);
    // } catch (java.lang.InternalError e1){
    // System.out.println("Error with class "+n+" "+e1);
    // }
    //System.out.println("------------");
    // --
    System.exit(result.wasSuccessful() ? 0 : 1); // this is needed because the test may start the AWT EventQueue thread which is not a daemon.
}

From source file:Main.java

private static File getLocationsFile(Context context) {
    return new File(context.getFilesDir().getPath() + File.pathSeparator + PIT_LOCATIONS_FILENAME);
}

From source file:Main.java

public static File getInternalFileObject(String uri, Context context) {
    if (!uri.contains(File.pathSeparator)) {
        return new File(context.getFilesDir(), uri);
    }//from   ww  w  .  j a va 2  s. c  o  m
    return null;
}

From source file:Main.java

/**
 * Ensures that the given pathname ends with the path separator character
 * of this operating system.//from w w  w  .j  a  v a  2s .  co  m
 * 
 * @param pathName
 * @return
 */
public final static String ensureEndsWithPathSeparatorChar(String pathName) {
    if (pathName.length() == 0)
        return File.pathSeparator;
    else if (pathName.charAt(pathName.length() - 1) == File.pathSeparatorChar)
        return pathName;
    else
        return pathName + File.pathSeparatorChar;
}

From source file:com.ejisto.util.ContainerUtils.java

public static String extractAgentJar(String classPath) {
    String systemProperty = System.getProperty("ejisto.agent.jar.path");
    if (StringUtils.isNotBlank(systemProperty)) {
        return systemProperty;
    }// w ww  .j a v a 2s  .  c  om

    final Optional<String> agentPath = Arrays.stream(classPath.split(Pattern.quote(File.pathSeparator)))
            .filter(e -> AGENT_JAR.matcher(e).matches()).findFirst();
    if (agentPath.isPresent()) {
        return Paths.get(System.getProperty("user.dir"), agentPath.get()).toString();
    }
    throw new IllegalStateException("unable to find agent jar");
}

From source file:Main.java

private static String getProgramName() {
    String p = System.getProperty("program");
    if (p != null)
        return p;

    String cp = System.getProperty("java.class.path");
    if (cp.indexOf(File.pathSeparator) == -1) {
        File f = new File(cp);
        if (f.getName().equals("jtreg.jar"))
            return "java -jar jtreg.jar ";
    }//from w  w w .jav a  2  s. c  om

    return "java " + Main.class.getName();
}