Get name of specified file or directory - Java File Path IO

Java examples for File Path IO:Directory

Description

Get name of specified file or directory

Demo Code

import java.io.*;
 
public class Main {
 
  public static void main(String[] args) {
    File file = new File("C://Folder//FileDemo.txt");
   /*  w  w  w .  ja  v  a  2  s.c o m*/
     String strFileName = file.getName();
   
     System.out.println("File name is : " + strFileName);
   
  }
}

Result


Related Tutorials