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

11
LINES

< > BotCompany Repo | #1019069 // countTillNewFileOrKeep - create file.txt, file2.txt etc. (also works for directories)

JavaX fragment (include)

static File countTillNewFileOrKeep(File base) {
  ret countTillNewFileOrKeep(base, "");
}

static File countTillNewFileOrKeep(File base, S suffix) {
  File f = newFile(f2s(base) + suffix);
  long i = 1;
  while (f.exists())
    f = newFile(f2s(base) + ++i + suffix);
  ret f;
}

Author comment

Began life as a copy of #1009771

download  show line numbers  debug dex  old transpilations   

Travelled to 12 computer(s): bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1019069
Snippet name: countTillNewFileOrKeep - create file.txt, file2.txt etc. (also works for directories)
Eternal ID of this version: #1019069/2
Text MD5: 204ffc5792f1993daedbfc4df2e6ef33
Author: stefan
Category: javax / io
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-10-22 01:01:40
Source code size: 287 bytes / 11 lines
Pitched / IR pitched: No / No
Views / Downloads: 272 / 318
Version history: 1 change(s)
Referenced in: [show references]