Get name of parent directory - Java File Path IO

Java examples for File Path IO:Directory

Description

Get name of parent directory

Demo Code

 
import java.io.*;
 
 
public class Main {
 
  public static void main(String[] args) {
    File file = new File("C://MyFolder/demo.txt");
     String strParentDirectory = file.getParent();
     System.out.println("Parent directory is : " + strParentDirectory);
  }//from  ww w  .j a v a  2 s.  c  om
}

Result


Related Tutorials