Example usage for java.nio.file Paths get

List of usage examples for java.nio.file Paths get

Introduction

In this page you can find the example usage for java.nio.file Paths get.

Prototype

public static Path get(URI uri) 

Source Link

Document

Converts the given URI to a Path object.

Usage

From source file:Test.java

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

    Path listing = Paths.get("/usr/bin/zip");

    System.out.println("Root of Path [" + listing.getRoot() + "]");

}

From source file:Main.java

public static void main(String[] args) throws Exception {
    Path p1 = Paths.get("Java_Dev");
    Path p2 = Paths.get("Java_Dev", "recent", "Test");
    System.out.println(p1.relativize(p2));
    System.out.println(p2.relativize(p1));

    Path p3 = Paths.get("Abc");
    Path p4 = Paths.get("Def");
    System.out.println(p3.relativize(p4));
    System.out.println(p4.relativize(p3));
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    Path p1 = Paths.get("C:\\Java_Dev\\..\\\\Java_Dev\\test1.txt");
    Path p1n = p1.normalize();//  w  w  w  .j  a va 2 s.c o m
    System.out.println(p1 + "  normalized to " + p1n);

    Path p2 = Paths.get("C:\\Java_Dev\\test1.txt");
    Path p2n = p2.normalize();
    System.out.println(p2 + "  normalized to " + p2n);

    Path p3 = Paths.get("\\..\\.\\test.txt");
    Path p3n = p3.normalize();
    System.out.println(p3 + "  normalized to " + p3n);
}

From source file:Main.java

public static void main(String[] args) {

    Path path = Paths.get(URI.create("file:///tutorial/Java/JavaFX/Topic.txt"));
    System.out.println(path);//from  w w  w .j  ava 2  s.  c o  m

    path = Paths.get(URI.create("file:///C:/tutorial/Java/JavaFX/Topic.txt"));
    System.out.println(path);

}

From source file:Main.java

public static void main(String[] args) {

    Path path01 = Paths.get("Topic.txt");
    Path path02 = Paths.get("Demo.txt");
    Path path03 = Paths.get("/Java/JavaFX/Topic.txt");
    Path path04 = Paths.get("/Java/2011");

    Path path01_to_path02 = path01.relativize(path02);
    System.out.println(path01_to_path02);

    Path path02_to_path01 = path02.relativize(path01);
    System.out.println(path02_to_path01);

    Path path03_to_path04 = path03.relativize(path04);
    System.out.println(path03_to_path04);

    Path path04_to_path03 = path04.relativize(path03);
    System.out.println(path04_to_path03);
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    Path path = Paths.get(new URI("C:/home/./music/users.txt"));
    System.out.println(path);//w  w w. j a  va2  s .  c  o  m
    System.out.println("Normalized: " + path.normalize());
}

From source file:Test.java

public static void main(String[] args) throws Exception {
    Path zip = Paths.get("/usr/bin/zip");
    System.out.println(Files.isDirectory(zip));
}

From source file:Test.java

public static void main(String[] args) throws Exception {
    Path zip = Paths.get("/usr/bin/zip");
    System.out.println(Files.size(zip));
}

From source file:Test.java

public static void main(String[] args) throws Exception {
    Path zip = Paths.get("/usr/bin/zip");
    System.out.println(Files.readAttributes(zip, "*"));
}

From source file:Main.java

public static void main(String[] args) {

    Path path = Paths.get("tutorial/Java/JavaFX/Topic.txt");
    System.out.println(path);/*from   w w w  .  j  av  a2s  . co  m*/

    path = Paths.get("/tutorial", "Java/JavaFX/Topic.txt");
    System.out.println(path);

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

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

    path = Paths.get("C:", "tutorial", "Java", "JavaFX", "Topic.txt");
    System.out.println(path);

    path = Paths.get("C:/tutorial/Java/JavaFX/Topic.txt");
    System.out.println(path);

    path = Paths.get("C:/tutorial/Java/JavaFX/dummy/../Topic.txt").normalize();
    System.out.println(path);

    path = Paths.get("C:/tutorial/Java/./JavaFX/dummy/../Topic.txt").normalize();
    System.out.println(path);

}