Create an absolute path - Java File Path IO

Java examples for File Path IO:Path

Description

Create an absolute path

Demo Code

import java.net.URI;
import java.nio.file.FileSystems;
import java.nio.file.Path;
import java.nio.file.Paths;

public class Main {

    public static void main(String[] args) {
        Path path10 = Paths.get("C:/folder1/folder2/folder4", "test.txt");
        Path path11 = Paths.get("C:", "folder1/folder2/folder4", "test.txt");
        Path path12 = Paths.get("C:", "folder1", "folder2", "2009", "test.txt");
        Path path13 = Paths.get("C:/folder1/folder2/folder3/test.txt");
        Path path14 = Paths.get(System.getProperty("user.home"), "downloads", "test1.txt");
        Path path15 = Paths.get(URI.create("file:///C:/folder1/folder2/folder3/test.txt"));
    }//from  w  ww .  ja va2  s .c om
}

Related Tutorials