Create a path relative to current folder - Java File Path IO

Java examples for File Path IO:Path


Create a path relative to current folder

Demo Code

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

public class Main {

    public static void main(String[] args) {

        //define a path relative to root, C:/, D:/ etc
        Path path06 = Paths.get("folder1/folder2/folder3/test.txt");
        Path path07 = Paths.get("folder1", "folder2/folder3/test.txt");
        Path path08 = FileSystems.getDefault().getPath("folder1/folder2/folder4", "test.txt");
        Path path09 = FileSystems.getDefault().getPath("folder1/folder2/folder3/test.txt");
       /*from w  w w. ja  v a  2s  . co  m*/

Related Tutorials