Get parent directory as a File object - Java File Path IO

Java examples for File Path IO:Directory

Description

Get parent directory as a File object

Demo Code

 
import java.io.*;
 
public class Main {
 
  public static void main(String[] args) {
    File file = new File("C://Folder/demo.txt");
    File fileParent = file.getParentFile();
    System.out.println("Parent directory is : " + fileParent.getPath());
  }//from   ww  w  . ja v a  2 s  . com
}

Result


Related Tutorials