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 .ja v a 2 s  .  com*/
      // dir is a directory
    } else {
      // dir is a file
    }
  }
}

Related Tutorials