Here you can find the source of makeDirsFor(File file)
Parameter | Description |
---|---|
file | non-null; the file to make directories for |
static public void makeDirsFor(File file)
//package com.java2s; // the rights to use, copy, modify, merge, publish, distribute, sublicense, import java.io.File; public class Main { /**//from w ww .j a v a 2s . c o m * Make the directories for the given file to exist in, if they don't * already exist. That is, make directories for all but the last * component of the given file. Also make sure the final directory is * writable, throwing an exception if that is not the case. * * @param file non-null; the file to make directories for */ static public void makeDirsFor(File file) { if (file == null) { throw new NullPointerException("file == null"); } File parent = file.getParentFile(); if (!parent.exists()) { if (!parent.mkdirs()) { throw new RuntimeException("Unable to make directory: " + parent); } } if (!parent.isDirectory()) { throw new RuntimeException("Not a directory: " + parent); } if (!parent.canWrite()) { throw new RuntimeException("Unable to write to directory: " + parent); } } }