What is the difference between File.mkdir() and File.mkdirs() methods ?

The difference is hidden under the "s" which is missing in the first method. In fact, mkdir() will create only demanded directory. If some of parent directories doesn't exist, this method will return false. mkdirs() will create the last directory with all missing parent directories. Take a look on following example:

public class MakingDirTest {

	public void test() {
		String tmpBaseDir = "/home/bartosz/";
		String directoryOk = tmpBaseDir+"new-directory";
		String parent = "test-parent/";
		String dir = "test";
		// delete directories if exist
		new File(directoryOk).delete();
		new File(tmpBaseDir+parent+dir).delete();
		new File(tmpBaseDir+parent).delete();
		boolean okMade = new File(directoryOk).mkdir(); // true
		boolean nokMade = new File(tmpBaseDir+parent+dir).mkdir(); // false
		boolean okParentMade = new File(tmpBaseDir+parent+dir).mkdirs(); // true
		assertTrue(directoryOk + " shouldn't be made", okMade);
		assertFalse(tmpBaseDir+parent+dir+ " shouldn't be made with mkdir method", nokMade);
		assertTrue(tmpBaseDir+parent+dir + " should be made with mkdirs method", okParentMade);