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

public static void main(String[] args) {

    System.out.println(File.pathSeparatorChar);

}

From source file:FileDemo.java

public static void main(String args[]) throws Exception {

    // Display constants
    System.out.println("pathSeparatorChar = " + File.pathSeparatorChar);
    System.out.println("separatorChar = " + File.separatorChar);

}

From source file:FileDemo.java

public static void main(String args[]) throws Exception {

    // Display constants
    System.out.println("pathSeparatorChar = " + File.pathSeparatorChar);
    System.out.println("separatorChar = " + File.separatorChar);

    // Test some methods
    File file = new File(args[0]);
    System.out.println("getName() = " + file.getName());
    System.out.println("getParent() = " + file.getParent());
    System.out.println("getAbsolutePath() = " + file.getAbsolutePath());
    System.out.println("getCanonicalPath() = " + file.getCanonicalPath());
    System.out.println("getPath() = " + file.getPath());
    System.out.println("canRead() = " + file.canRead());
    System.out.println("canWrite() = " + file.canWrite());
}

From source file:MainClass.java

public static void main(String args[]) {

    try {// ww  w .ja  va 2  s .c  om

        System.out.println("pathSeparatorChar = " + File.pathSeparatorChar);

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

From source file:org.esa.beam.extapi.gen.ApiGeneratorDoclet.java

public static void main(String[] args) throws JDOMException, IOException {
    if (args.length != 1) {
        System.out.println("Usage:");
        System.out.println("    ApiGeneratorDoclet <beamSourceDir>");
        System.exit(-1);/*from www. java  2s .  c  om*/
    }
    final DefaultHandler handler = new DefaultHandler(args[0]);
    final String sourcePaths = StringUtils.join(handler.config.getSourcePaths(), File.pathSeparatorChar);
    run(handler, sourcePaths, handler.config.getPackages());
}

From source file:fr.inria.lille.repair.nopol.NoPolLauncher.java

public static void main(String[] args) {
    String filePath = "misc/nopol-example/src/";
    String binFolder = "misc/nopol-example/bin/";
    String junitJar = "misc/nopol-example/junit-4.11.jar";
    String classpath = binFolder + File.pathSeparatorChar + junitJar;
    String type = args[0];//  w w w .  j  ava  2  s. co m
    String solverName = args[1];
    String solverPath = args[2];
    System.out.println(format("args:\n\t%s\n\t%s\n\t%s\n\t%s", filePath, classpath, solverName, solverPath));
    Main.main(new String[] { "repair", type, "angelic", filePath, classpath, solverName, solverPath });
    System.exit(1);
}

From source file:com.jbrisbin.groovy.mqdsl.RabbitMQDsl.java

public static void main(String[] argv) {

    // Parse command line arguments
    CommandLine args = null;/*ww  w  . j  a  va2  s.  c  om*/
    try {
        Parser p = new BasicParser();
        args = p.parse(cliOpts, argv);
    } catch (ParseException e) {
        log.error(e.getMessage(), e);
    }

    // Check for help
    if (args.hasOption('?')) {
        printUsage();
        return;
    }

    // Runtime properties
    Properties props = System.getProperties();

    // Check for ~/.rabbitmqrc
    File userSettings = new File(System.getProperty("user.home"), ".rabbitmqrc");
    if (userSettings.exists()) {
        try {
            props.load(new FileInputStream(userSettings));
        } catch (IOException e) {
            log.error(e.getMessage(), e);
        }
    }

    // Load Groovy builder file
    StringBuffer script = new StringBuffer();
    BufferedInputStream in = null;
    String filename = "<STDIN>";
    if (args.hasOption("f")) {
        filename = args.getOptionValue("f");
        try {
            in = new BufferedInputStream(new FileInputStream(filename));
        } catch (FileNotFoundException e) {
            log.error(e.getMessage(), e);
        }
    } else {
        in = new BufferedInputStream(System.in);
    }

    // Read script
    if (null != in) {
        byte[] buff = new byte[4096];
        try {
            for (int read = in.read(buff); read > -1;) {
                script.append(new String(buff, 0, read));
                read = in.read(buff);
            }
        } catch (IOException e) {
            log.error(e.getMessage(), e);
        }
    } else {
        System.err.println("No script file to evaluate...");
    }

    PrintStream stdout = System.out;
    PrintStream out = null;
    if (args.hasOption("o")) {
        try {
            out = new PrintStream(new FileOutputStream(args.getOptionValue("o")), true);
            System.setOut(out);
        } catch (FileNotFoundException e) {
            log.error(e.getMessage(), e);
        }
    }

    String[] includes = (System.getenv().containsKey("MQDSL_INCLUDE")
            ? System.getenv("MQDSL_INCLUDE").split(String.valueOf(File.pathSeparatorChar))
            : new String[] { System.getenv("HOME") + File.separator + ".mqdsl.d" });

    try {
        // Setup RabbitMQ
        String username = (args.hasOption("U") ? args.getOptionValue("U")
                : props.getProperty("mq.user", "guest"));
        String password = (args.hasOption("P") ? args.getOptionValue("P")
                : props.getProperty("mq.password", "guest"));
        String virtualHost = (args.hasOption("v") ? args.getOptionValue("v")
                : props.getProperty("mq.virtualhost", "/"));
        String host = (args.hasOption("h") ? args.getOptionValue("h")
                : props.getProperty("mq.host", "localhost"));
        int port = Integer.parseInt(
                args.hasOption("p") ? args.getOptionValue("p") : props.getProperty("mq.port", "5672"));

        CachingConnectionFactory connectionFactory = new CachingConnectionFactory(host);
        connectionFactory.setPort(port);
        connectionFactory.setUsername(username);
        connectionFactory.setPassword(password);
        if (null != virtualHost) {
            connectionFactory.setVirtualHost(virtualHost);
        }

        // The DSL builder
        RabbitMQBuilder builder = new RabbitMQBuilder();
        builder.setConnectionFactory(connectionFactory);
        // Our execution environment
        Binding binding = new Binding(args.getArgs());
        binding.setVariable("mq", builder);
        String fileBaseName = filename.replaceAll("\\.groovy$", "");
        binding.setVariable("log",
                LoggerFactory.getLogger(fileBaseName.substring(fileBaseName.lastIndexOf("/") + 1)));
        if (null != out) {
            binding.setVariable("out", out);
        }

        // Include helper files
        GroovyShell shell = new GroovyShell(binding);
        for (String inc : includes) {
            File f = new File(inc);
            if (f.isDirectory()) {
                File[] files = f.listFiles(new FilenameFilter() {
                    @Override
                    public boolean accept(File file, String s) {
                        return s.endsWith(".groovy");
                    }
                });
                for (File incFile : files) {
                    run(incFile, shell, binding);
                }
            } else {
                run(f, shell, binding);
            }
        }

        run(script.toString(), shell, binding);

        while (builder.isActive()) {
            try {
                Thread.sleep(500);
            } catch (InterruptedException e) {
                log.error(e.getMessage(), e);
            }
        }

        if (null != out) {
            out.close();
            System.setOut(stdout);
        }

    } finally {
        System.exit(0);
    }
}

From source file:Main.java

public static String getClasspathString(List<File> c) {
    StringBuilder sb = new StringBuilder();
    Iterator<File> i = c.iterator();
    if (i.hasNext()) {
        sb.append(i.next().getAbsolutePath());
        while (i.hasNext()) {
            sb.append(File.pathSeparatorChar);
            sb.append(i.next().getAbsolutePath());
        }/*from w  ww.j a v  a 2  s .co m*/
    }
    return sb.toString();
}

From source file:Main.java

/**
 * Ensures that the given pathname ends with the path separator character
 * of this operating system./*from  www  .ja  va 2 s.  c  o  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:Main.java

/**
 * Ensures that the given pathname does not end with the path separator character
 * of this operating system./*from w  w w  .  j  a va  2  s .co m*/
 * 
 * @param pathName
 * @return
 */
public final static String ensureEndsNotWithPathSeparatorChar(String pathName) {
    if (pathName.length() == 0)
        return pathName;
    else if (pathName.charAt(pathName.length() - 1) != File.pathSeparatorChar)
        return pathName;
    else
        return pathName.substring(0, pathName.length() - 1);
}