Java File.getPath()

Syntax

File.getPath() has the following syntax.

public String getPath()

Example

In the following code shows how to use File.getPath() method.


//from ww w.  jav  a  2 s . c  o m

import java.io.File;

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

    // create new files
    File f = new File("c:/asdf/");


    System.out.print(f.getPath());

  }
}

The code above generates the following result.