Here you can find the source of mkdirs(File directory)
public static boolean mkdirs(File directory)
//package com.java2s; /******************************************************************************* * Copyright (c) 2010-2011 Sonatype, Inc. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html *******************************************************************************/ import java.io.File; import java.io.IOException; public class Main { public static boolean mkdirs(File directory) { if (directory == null) { return false; }/* www . jav a 2 s .c om*/ if (directory.exists()) { return false; } if (directory.mkdir()) { return true; } File canonDir = null; try { canonDir = directory.getCanonicalFile(); } catch (IOException e) { return false; } File parentDir = canonDir.getParentFile(); return (parentDir != null && (mkdirs(parentDir) || parentDir.exists()) && canonDir.mkdir()); } }