Java IO Tutorial - Java File.mkdir()


File.mkdir() has the following syntax.

public boolean mkdir()


In the following code shows how to use File.mkdir() method.

/* w  ww  .j a  v a2 s  . c o m*/

public class Main {
  public static void main(String[] args) {

    // returns pathnames for files and directory
    File f = new File("C:/Texts");

    // create
    boolean bool = f.mkdir();

    System.out.print("Directory created? " + bool);


The code above generates the following result.