Example usage for java.nio.file Path toString

List of usage examples for java.nio.file Path toString

Introduction

In this page you can find the example usage for java.nio.file Path toString.

Prototype

String toString();

Source Link

Document

Returns the string representation of this path.

Usage

From source file:Main.java

public static void main(String[] args) {

    //define the fix path
    Path base_1 = Paths.get("C:/tutorial/Java/JavaFX");
    Path base_2 = Paths.get("C:/tutorial/Java/JavaFX/Topic.txt");

    //resolve sibling Demo.txt file
    Path path_3 = base_2.resolveSibling("Demo.txt");
    System.out.println(path_3.toString());

}

From source file:Main.java

public static void main(String[] args) {

    //define the fix path
    Path base_1 = Paths.get("C:/tutorial/Java/JavaFX");
    Path base_2 = Paths.get("C:/tutorial/Java/JavaFX/Topic.txt");

    //resolve Topic.txt file
    Path path_1 = base_1.resolve("Topic.txt");
    System.out.println(path_1.toString());

    //resolve Demo.txt file
    Path path_2 = base_1.resolve("Demo.txt");
    System.out.println(path_2.toString());

}

From source file:Main.java

public static void main(String[] args) {

    Path path = Paths.get("C:", "tutorial/Java/JavaFX", "Topic.txt");

    System.out.println(path.toString());
}

From source file:Test.java

public static void main(String[] args) {
    Path path = FileSystems.getDefault().getPath("/home/docs/status.txt");

    System.out.println(path.toString());
}

From source file:Main.java

public static void main(String[] args) {

    Path path = Paths.get("C:", "tutorial/Java/JavaFX", "Topic.txt");

    //convert relative path to absolute path
    Path path_to_absolute_path = path.toAbsolutePath();
    System.out.println("Path to absolute path: " + path_to_absolute_path.toString());
}

From source file:Main.java

public static void main(String[] args) {

    Path basedir = FileSystems.getDefault().getPath("C:/tutorial/tmp/");
    String tmp_dir_prefix = "Swing_";

    //get the default temporary folders path
    String default_tmp = System.getProperty("java.io.tmpdir");
    System.out.println(default_tmp);

    try {/*from   ww  w .  jav  a2  s  .co  m*/
        //set a prefix
        Path tmp_2 = Files.createTempDirectory(tmp_dir_prefix);
        System.out.println("TMP: " + tmp_2.toString());

    } catch (IOException e) {
        System.err.println(e);
    }
}

From source file:Main.java

public static void main(String[] args) {

    Path basedir = FileSystems.getDefault().getPath("C:/tutorial/tmp");
    String tmp_file_prefix = "Swing_";
    String tmp_file_sufix = ".txt";

    //get the default temporary folders path
    String default_tmp = System.getProperty("java.io.tmpdir");
    System.out.println(default_tmp);

    try {/*from   w  w  w.j  a  v  a2  s .co m*/
        //set a prefix and a sufix
        Path tmp_2 = Files.createTempFile(tmp_file_prefix, tmp_file_sufix);
        System.out.println("TMP: " + tmp_2.toString());

    } catch (IOException e) {
        System.err.println(e);
    }

}

From source file:Main.java

public static void main(String[] args) {

    Path basedir = FileSystems.getDefault().getPath("C:/tutorial/tmp");
    String tmp_file_prefix = "Swing_";
    String tmp_file_sufix = ".txt";

    //get the default temporary folders path
    String default_tmp = System.getProperty("java.io.tmpdir");
    System.out.println(default_tmp);

    try {//from www  . ja va 2  s .co  m
        //create a tmp file in a the base dir
        Path tmp_3 = Files.createTempFile(basedir, tmp_file_prefix, tmp_file_sufix);
        System.out.println("TMP: " + tmp_3.toString());

    } catch (IOException e) {
        System.err.println(e);
    }
}

From source file:Main.java

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

    Path rootDirectory = FileSystems.getDefault().getPath("C:/home/docs");

    Path tempDirectory = Files.createTempDirectory(rootDirectory, "");
    System.out.println("Temporary directory created successfully!");
    String dirPath = tempDirectory.toString();
    System.out.println(dirPath);//from  w  ww  .  j  a  v  a  2  s  . c  o  m
    Path tempFile = Files.createTempFile(tempDirectory, "", "");
    System.out.println("Temporary file created successfully!");
    String filePath = tempFile.toString();
    System.out.println(filePath);
}

From source file:com.acmutv.ontoqa.GrammalexMain.java

/**
 * The app main method, executed when the program is launched.
 * @param args The command line arguments.
* @throws IllegalAccessException /*from w w w . j a va 2 s .  com*/
* @throws InstantiationException 
 */
public static void main(String[] args) throws InstantiationException, IllegalAccessException {
    //CliService.handleArguments(args);
    RuntimeManager.registerShutdownHooks(new ShutdownHook());
    try {

        Path path = FileSystems.getDefault().getPath("data/lexicon").toAbsolutePath();
        String currentDirectory = path.toString();
        final JFileChooser fc = new JFileChooser(currentDirectory);

        int returnVal = fc.showOpenDialog(null);
        fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
        if (returnVal == JFileChooser.OPEN_DIALOG) {
            File file = fc.getSelectedFile();
            System.out.println("File Select: " + file.getName() + "\n\n");
            List<LexicalEntry> lEntries = LexiconUsage.getLexicalEntries(file.getAbsolutePath(), "",
                    LexiconFormat.RDFXML);
            Grammar grammar = SerializeSltag.getAllElementarySltag(lEntries);
            SerializeSltag.writeGrammarOnFile(grammar, fileJson);
        }

    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    System.exit(0);
}