Java IO Tutorial - 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.

//w  w  w. ja v 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.