Does anyone know how to use Java to create sub-directories based on the alphabets (a-z) that is n levels deep?
/a
/a
/a
/b
/c
Scala code:
def makePathRecursive(path: String) = {
import java.io.File
import scala.util.{Try, Failure, Success}
val pathObj = new File(path)
pathObj.exists match {
case true => // do nothing
case false => Try(pathObj.mkdirs) match {
case Success(_) => // it worked
case Failure(e) => // maybe created meanwhile by another thread
pathObj.exists match {
case false => throw new Exception(e)
case _ =>
}
}
}
}