Answers for "mkdirs for java"

0

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");
    }
  }
}
Posted by: Guest on February-21-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language