Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

15
LINES

< > BotCompany Repo | #1000827 // mkdirsForFile

JavaX fragment (include)

public static File mkdirsForFile(File file) {
  File dir = file.getParentFile();
  if (dir != null) { // is null if file is in current dir
    dir.mkdirs();
    if (!dir.isDirectory())
      if (dir.isFile()) fail("Please delete the file " + f2s(dir) + " - it is supposed to be a directory!");
      else fail("Unknown IO exception during mkdirs of " + f2s(file));
  }
  ret file;
}

public static S mkdirsForFile(S path) {
  mkdirsForFile(new File(path));
  ret path;
}

download  show line numbers  debug dex  old transpilations   

Travelled to 17 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, jtubtzbbkimh, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, sawdedvomwva, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1000827
Snippet name: mkdirsForFile
Eternal ID of this version: #1000827/7
Text MD5: a4f55f6e502e5c9550f4f1c87f261e66
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-06-15 19:29:23
Source code size: 484 bytes / 15 lines
Pitched / IR pitched: No / No
Views / Downloads: 685 / 3415
Version history: 6 change(s)
Referenced in: #1002427 - Accellerating 629 (SPIKE)
#1004007 - mkdir - synonym of File.mkdirs
#1004275 - mkdirsFor - synonym of mkdirsForFile
#1005694 - prepareFile - extended synonym of mkdirsForFile
#1006654 - Standard functions list 2 (LIVE, continuation of #761)
#3000382 - Answer for ferdie (>> t = 1, f = 0)