How to get file path 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 {

        try {

            File file = new File("d:\\directx\\ConsoleApplication_C++\\Source.cpp");
            
            System.out.println(file.getPath());

        } catch (Exception e) {
            System.out.print(e);
        }
    }
}


/*
        
run:
  
d:\directx\ConsoleApplication_C++\Source.cpp

 */

 



answered Nov 17, 2016 by avibootz

Related questions

1 answer 173 views
3 answers 278 views
2 answers 213 views
1 answer 190 views
...