best to use java mkdir code example

Example: best to use java mkdir

import java.io.File;

// demonstrates how to create a directory in java
public class JavaCreateDirectoryExample
{
  public static void main(String[] args)
  {
    File dir = new File("/Users/al/tmp/TestDirectory");
    
    // attempt to create the directory here
    boolean successful = dir.mkdir();
    if (successful)
    {
      // creating the directory succeeded
      System.out.println("directory was created successfully");
    }
    else
    {
      // creating the directory failed
      System.out.println("failed trying to create the directory");
    }
  }
}

Tags:

Misc Example