Here you can find the source of mkdir(File dir)
Parameter | Description |
---|---|
dir | the directory to be created. |
Parameter | Description |
---|---|
IOException | if the file could not be created. |
public static void mkdir(File dir) throws IOException
//package com.java2s; //License from project: Apache License import java.io.*; public class Main { /**//from w w w . j a va 2 s .com * Creates the given directory. * * @param dir the directory to be created. * @throws IOException if the file could not be created. * @see File#mkdir() */ public static void mkdir(File dir) throws IOException { if (!dir.exists() || !dir.isDirectory()) { if (!dir.mkdir()) { throw new IOException("Failed to create directory " + dir); } } } /** * Return true or false based on whether the named file exists. */ static public boolean exists(String filename) throws IOException { try { return (new File(filename)).exists(); } catch (Throwable e) { throw toIOException(e); } } static IOException toIOException(Throwable e) { if (e instanceof IOException) { return (IOException) e; } else { return new IOException(e.getMessage()); } } }