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)

1  
static File countTillNewFileOrKeep(File base) {
2  
  ret countTillNewFileOrKeep(base, "");
3  
}
4  
5  
static File countTillNewFileOrKeep(File base, S suffix) {
6  
  File f = newFile(f2s(base) + suffix);
7  
  long i = 1;
8  
  while (f.exists())
9  
    f = newFile(f2s(base) + ++i + suffix);
10  
  ret f;
11  
}

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: 407 / 439
Version history: 1 change(s)
Referenced in: [show references]