Here you can find the source of mkdir(String directory)
Parameter | Description |
---|---|
directory | The directory to create. |
Parameter | Description |
---|---|
IOException | if I/O exception |
public static void mkdir(String directory) throws IOException
//package com.java2s; import java.io.File; import java.io.IOException; public class Main { /**//from ww w . j av a 2s . co m * This method creates the specified directory. * * @param directory The directory to create. * @throws IOException if I/O exception */ public static void mkdir(String directory) throws IOException { File f = new File(directory); if (f.exists()) { if (f.isFile()) { throw new IOException("Error creating directory:" + directory); //$NON-NLS-1$ } } else { if (!f.mkdirs()) { throw new IOException("Error creating directory:" + directory); //$NON-NLS-1$ } } } }