Perhaps because File.mkdir only creates a directory if a parent directory exists. Try using File.mkdirs , which creates all the necessary directories.
Here is the code that worked for me.
private void writeDir(File f){ try{ if(f.mkdirs()) { System.out.println("Directory Created"); } else { System.out.println("Directory is not created"); } } catch(Exception e){
The only change I made was to change f.mkdir() to f.mkdirs() and it worked
La bla bla
source share