Determining If a Filename Path Is a File or a Directory - Java File Path IO

Java examples for File Path IO:Path

Description

Determining If a Filename Path Is a File or a Directory

Demo Code

import java.awt.Graphics;
import java.io.File;

public class Main {
  public void m() {
    File dir = new File("directoryName");

    boolean isDir = dir.isDirectory();
    if (isDir) {/*  w  w w  . j  a v a  2s  .  c o m*/
      // dir is a directory
    } else {
      // dir is a file
    }
  }
}

Related Tutorials