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) {/*  ww  w .  java 2  s.  c  o  m*/
      // dir is a directory
    } else {
      // dir is a file
    }
  }
}

Related Tutorials