Example usage for java.io File getCanonicalPath

List of usage examples for java.io File getCanonicalPath

Introduction

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

Prototype

public String getCanonicalPath() throws IOException 

Source Link

Document

Returns the canonical pathname string of this abstract pathname.

Usage

From source file:Main.java

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

    // create new files
    File f = new File("test.txt");

    String path = f.getCanonicalPath();

    System.out.print("Absolute Pathname " + path);

}

From source file:MainClass.java

public static void main(String[] a) throws Exception {
    File tmp = File.createTempFile("foo", "tmp");
    System.out.println("Your temp file is " + tmp.getCanonicalPath());
}

From source file:MainClass.java

public static void main(String args[]) {

    try {/*from  w w w  . ja  v a 2 s . c om*/

        File file = new File("c:\\winnt");
        System.out.println("getCanonicalPath() = " + file.getCanonicalPath());

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

From source file:PathInfo.java

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

    File f = new File(args[0]);

    System.out.println("Absolute path = " + f.getAbsolutePath());
    System.out.println("Canonical path = " + f.getCanonicalPath());
    System.out.println("Name = " + f.getName());
    System.out.println("Parent = " + f.getParent());
    System.out.println("Path = " + f.getPath());
    System.out.println("Absolute? = " + f.isAbsolute());
}

From source file:edu.harvard.mcz.imagecapture.BarcodeReadTest.java

/**
 * Launches the application, checking one image file for a barcode.
 * /* w w w. ja va  2s  .  c  om*/
 * @param args takes filename to read as the first argument.
 */
public static void main(String[] args) {
    if (args.length == 0) {
        System.out.println("java BarcodeReadTest filename");
    } else {
        String filename = args[0];
        File file = new File(filename);
        try {
            log.debug(file.getCanonicalPath());
            BufferedImage image = ImageIO.read(file);
            System.out.println(checkForBarcode(image));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

From source file:fi.jasoft.plugin.LibSassCompiler.java

public static void main(String[] args) throws Exception {
    File inputFile = new File(args[0]);
    File outputFile = new File(args[1]);
    if (!outputFile.exists()) {
        outputFile.createNewFile();/*w w w. j a v  a 2  s .  c om*/
    }

    File sourceMapFile = new File(args[1] + ".map");
    if (!sourceMapFile.exists()) {
        sourceMapFile.createNewFile();
    }

    File unpackedThemes = new File(args[2]);
    File unpackedInputFile = Paths
            .get(unpackedThemes.getCanonicalPath(), inputFile.getParentFile().getName(), inputFile.getName())
            .toFile();

    Compiler compiler = new Compiler();
    Options options = new Options();

    try {
        Output output = compiler.compileFile(unpackedInputFile.toURI(), outputFile.toURI(), options);
        FileUtils.write(outputFile, output.getCss(), StandardCharsets.UTF_8.name());
        FileUtils.write(sourceMapFile, output.getSourceMap(), StandardCharsets.UTF_8.name());
    } catch (CompilationException e) {
        outputFile.delete();
        sourceMapFile.delete();
        throw e;
    }
}

From source file:dk.dren.hunspell.HunspellMain.java

public static void main(String[] args) {
    try {// ww  w.  j  av a  2s.c  o m
        if (args.length == 1 && args[0].equals("-libname")) {
            System.out.println(Hunspell.libName());

        } else {

            System.out.println("Loading Hunspell");

            File dir = new File("src/main/resources/dict");
            String dirPath = dir.getCanonicalPath() + "/pt_BR";

            Hunspell.Dictionary d = Hunspell.getInstance().getDictionary(dirPath);

            System.out.println("Hunspell library and dictionary loaded");

            String words[] = { "subnutido", "isso", "nao" };

            for (int i = 0; i < words.length; i++) {

                String word = words[i];
                if (d.misspelled(word)) {
                    List<String> suggestions = d.suggest(word);
                    print("misspelled: " + word);
                    if (suggestions.isEmpty()) {
                        print("\tNo suggestions.");
                    } else {
                        print("\tTry:");
                        for (String s : suggestions) {
                            print(" " + s);
                        }
                    }
                    println("");
                } else {
                    println("ok: " + word);
                }
            }
        }

    } catch (Exception e) {
        log.error(e.getMessage(), e);
    }
}

From source file:com.cardFetcher.Core.NetrunnerCardFetcher.java

public static void main(String[] args) {
    //        String setsPath = "GameDatabase\\0f38e453-26df-4c04-9d67-6d43de939c77\\Sets";
    //        String imagesPath = "ImageDatabase\\0f38e453-26df-4c04-9d67-6d43de939c77\\Sets";
    String setsPath = "C:\\Users\\jose.gonzalez\\Documents\\OCTGN\\GameDatabase\\0f38e453-26df-4c04-9d67-6d43de939c77\\Sets";
    String imagesPath = "C:\\Users\\jose.gonzalez\\Documents\\OCTGN\\ImageDatabase\\0f38e453-26df-4c04-9d67-6d43de939c77\\Sets";
    //        String setsPath = "C:\\Users\\jgonzal2\\Documents\\OCTGN\\GameDatabase\\0f38e453-26df-4c04-9d67-6d43de939c77\\Sets";
    //        String imagesPath = "C:\\Users\\jgonzal2\\Documents\\OCTGN\\ImageDatabase\\0f38e453-26df-4c04-9d67-6d43de939c77\\Sets";

    try {/*w  w  w. ja  v a  2 s .c o m*/
        JSONArray json = JSONFetcher.getJSON();
        //System.out.println(json);
        File f = new File(setsPath);
        File[] files = f.listFiles();
        int count = 0;
        for (File file : files) {
            if (file.isDirectory()) {
                Set s = XmlParser.parseXML(file.getCanonicalPath() + "\\set.xml");

                if ((!s.getSetName().equals("Promos")) && (!s.getSetName().equals("Markers"))) {
                    //System.out.println(s);
                    ImageFetcher fetch = new ImageFetcher(s, imagesPath, json);
                    System.out.print("thread " + count++ + ": ");
                    fetch.start();
                }
            }
        }
    }

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

From source file:io.fluo.cluster.WorkerApp.java

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

    AppOptions options = new AppOptions();
    JCommander jcommand = new JCommander(options, args);

    if (options.displayHelp()) {
        jcommand.usage();//  www  .j a  va  2  s . co m
        System.exit(-1);
    }

    Logging.init("worker", options.getFluoHome() + "/conf", "STDOUT");

    File configFile = new File(options.getFluoHome() + "/conf/fluo.properties");
    FluoConfiguration config = new FluoConfiguration(configFile);
    if (!config.hasRequiredWorkerProps()) {
        log.error("fluo.properties is missing required properties for worker");
        System.exit(-1);
    }
    Environment env = new Environment(config);

    YarnConfiguration yarnConfig = new YarnConfiguration();
    yarnConfig.addResource(new Path(options.getHadoopPrefix() + "/etc/hadoop/core-site.xml"));
    yarnConfig.addResource(new Path(options.getHadoopPrefix() + "/etc/hadoop/yarn-site.xml"));

    TwillRunnerService twillRunner = new YarnTwillRunnerService(yarnConfig, env.getZookeepers());
    twillRunner.startAndWait();

    TwillPreparer preparer = twillRunner.prepare(new WorkerApp(options, config));

    // Add any observer jars found in lib observers
    File observerDir = new File(options.getFluoHome() + "/lib/observers");
    for (File f : observerDir.listFiles()) {
        String jarPath = "file:" + f.getCanonicalPath();
        log.debug("Adding observer jar " + jarPath + " to YARN app");
        preparer.withResources(new URI(jarPath));
    }

    TwillController controller = preparer.start();
    controller.start();

    while (controller.isRunning() == false) {
        Thread.sleep(2000);
    }
    env.close();
    System.exit(0);
}

From source file:TempFiles.java

public static void main(String[] argv) throws IOException {

    // 1. Make an existing file temporary

    // Construct a File object for the backup created by editing
    // this source file. The file probably already exists.
    // My editor creates backups by putting ~ at the end of the name.
    File bkup = new File("Rename.java~");
    // Arrange to have it deleted when the program ends.
    bkup.deleteOnExit();/* ww w .j ava 2 s  . co m*/

    // 2. Create a new temporary file.

    // Make a file object for foo.tmp, in the default temp directory
    File tmp = File.createTempFile("foo", "tmp");
    // Report on the filename that it made up for us.
    System.out.println("Your temp file is " + tmp.getCanonicalPath());
    // Arrange for it to be deleted at exit.
    tmp.deleteOnExit();
    // Now do something with the temporary file, without having to
    // worry about deleting it later.
    writeDataInTemp(tmp.getCanonicalPath());
}