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 zip = Paths.get("/usr/bin/zip");
    System.out.println(zip.toAbsolutePath().toString());
}

From source file:Test.java

public static void main(String[] args) throws Exception {
    Path path = Paths.get("users.txt");

    System.out.println("URI path: " + path.toUri());
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    Path p2 = Paths.get("test2.txt");
    java.net.URI p2UriPath = p2.toUri();
    System.out.println("Absolute Path: " + p2.toAbsolutePath());
    System.out.println("URI Path: " + p2UriPath);

}

From source file:Main.java

public static void main(String[] args) {
    Path p1 = Paths.get("C:\\Java_Dev\\test1.txt");
    printDetails(p1);/*www . j  ava 2s  . c  o m*/

    Path p2 = Paths.get("test1.txt");
    printDetails(p2);
}

From source file:Test.java

public static void main(String[] args) {
    Path path = Paths.get("/home/docs/../music/A.mp3");
    System.out.println("Absolute path: " + path.toAbsolutePath());
    System.out.println("URI: " + path.toUri());
    System.out.println("Normalized Path: " + path.normalize());
    System.out.println("Normalized URI: " + path.normalize().toUri());
    System.out.println();//from w  ww. ja  va  2s . c om

    path = Paths.get("/home/./music/A.mp3");
    System.out.println("Absolute path: " + path.toAbsolutePath());
    System.out.println("URI: " + path.toUri());
    System.out.println("Normalized Path: " + path.normalize());
    System.out.println("Normalized URI: " + path.normalize().toUri());

}

From source file:Main.java

public static void main(String[] args) throws Exception {
    Path p1 = Paths.get("C:\\Java_Dev\\test1.txt");
    Path p2 = Paths.get("C:\\Java_Dev\\LUCI1.TXT");
    Path p3 = Paths.get("C:\\Java_Dev\\..\\Java_Dev\\test1.txt");
    boolean b1 = p1.equals(p2);
    System.out.println(b1);/*from  w w w.ja  va 2  s. c  o  m*/
    boolean b2 = p1.equals(p3);
    System.out.println(b2);
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    Path p1 = Paths.get("C:\\Java_Dev\\test1.txt");
    Path p2 = Paths.get("C:\\Java_Dev\\Test1.txt");
    Path p3 = Paths.get("C:\\Java_Dev\\..\\Java_Dev\\test1.txt");
    int v1 = p1.compareTo(p2);
    System.out.println(v1);/*  w  w w. j a v a  2s. c  o  m*/
    int v2 = p1.compareTo(p3);
    System.out.println(v2);
}

From source file:Test.java

public static void main(String[] args) {
    Path rootPath = Paths.get("/home/docs");
    Path resolvedPath = rootPath.resolve("backup/users.txt");

    resolvedPath = rootPath.resolve("tmp/A.mp3");
    System.out.println("rootPath: " + rootPath);
    System.out.println("resolvedPath: " + resolvedPath);
    System.out.println();//from  ww w .  j av a  2s.co  m

    resolvedPath = rootPath.resolveSibling("tmp/A.mp3");
    System.out.println("rootPath: " + rootPath);
    System.out.println("resolvedPath: " + resolvedPath);

}

From source file:Test.java

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

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

    System.out.println("Parent Path [" + listing.getParent() + "]");
}

From source file:Test.java

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

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

    System.out.println("File Name [" + listing.getFileName() + "]");
}