How to construct a file path using File class in Java

1 Answer

0 votes
package javaapplication1;

import java.io.File;
import java.io.IOException;

public class JavaApplication1 {

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

        String filePath = "d:\\" + File.separator + "directx\\3d" + File.separator + "main.cpp";

        File file = new File(filePath);

        System.out.println(file.getPath());
    }
}

/*
       
run:
 
d:\directx\3d\main.cpp
   
 */

 



answered Nov 15, 2016 by avibootz

Related questions

...