Java-Get File Names

Get File Names

The list( ) method is used to get the file names. This method returns an array of strings naming the files and directories in the directory denoted by this abstract pathname.

Program

0

Program Source

import java.io.File;

public class Javaapp {

    public static void main(String[] args) {
        
        File f1 = new File("F:\\java8");
        System.out.println("Folder Name        : "+f1.getName());
        System.out.println("Full Path          : "+f1.getPath());
        System.out.println("Parent of          : "+f1.getParent());
        System.out.println("java8 Folder is    : "+f1.exists());
        System.out.println("java8 is a File    : "+f1.isFile());
    }
}

Leave a Comment