Determining If a File or Directory Exists - Java File Path IO

Java examples for File Path IO:Directory

Description

Determining If a File or Directory Exists

Demo Code

import java.io.File;

public class Main {
  public static void main(String[] args) {
    boolean exists = (new File("filename")).exists();
    if (exists) {
      // File or directory exists
    } else {/* ww w .j av  a  2 s  .  c o  m*/
      // File or directory does not exist
    }
  }
}

Related Tutorials