File IsDirectory() Example
Tests whether the file denoted by this abstract pathname is a directory.
File class IsDirectory() method example. This example shows you how to use IsDirectory method.This method Tests whether the file denoted by this abstract pathname is a directory.
Here is the code:-
/**
* @Program that Tests whether the file denoted by this abstract pathname
is a directory.
* IsDirectory.java
* Author:-RoseIndia Team
* Date:-30-May-2008
*/
import java.io.*;
public class IsDirectory {
public static void main(String[] args) {
File f = new File("/home/girish/Desktop/g.txt");
if (f.exists()) {
boolean b=f.isDirectory();
System.out.println("is Directory : " + b);
} else {
System.out.println("File does not exists");
}
}
} |
|