Java IO Tutorial - Java File.getParentFile()








Syntax

File.getParentFile() has the following syntax.

public File getParentFile()

Example

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

//from  w  w w.ja  v a2s .  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.getParentFile());

  }
}

The code above generates the following result.