How to find if a pathname is a directory in java?

Below java code shows how to find whether the specified path is directory or file –

/****************************************************************************************
* Created on 03-2012 Copyright(c) https://kodehelp.com All Rights Reserved.
****************************************************************************************/
package com.kodehelp.javaio;

import java.io.File;

/**
 * Created by https://kodehelp.com Date: 03/05/2012
 */
public class IsDirectoryDemo {

    public static void main(String[] args) {

        File file = new File("/home/kodehelp/");

        //
        // To check whether the path is directory or file, you need to call
        // isDirectory() method of the File class.
        //
        if (file.isDirectory()) {
            System.out.println("This file is a kodehelp directory.");
        } else {
            System.out.println("This is just a kodehelp file.");
        }

    }

}