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

7
LINES

< > BotCompany Repo | #1033396 // makeFileNameUnique_beforeExtension

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (4647L/26K).

1  
static File makeFileNameUnique_beforeExtension(File f) {
2  
  File orig = f;
3  
  int n = 0;
4  
  while (f.exists())
5  
    f = appendToFileBaseName(orig, "." + ++n);
6  
  ret f;
7  
}

Author comment

Began life as a copy of #1015318

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1033396
Snippet name: makeFileNameUnique_beforeExtension
Eternal ID of this version: #1033396/2
Text MD5: 007aa4bd66cf68dec70481a7d653b7ab
Transpilation MD5: 6a5e82d73d9f506ac67e59b65bc90154
Author: stefan
Category: javax / io
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-10-27 01:53:19
Source code size: 171 bytes / 7 lines
Pitched / IR pitched: No / No
Views / Downloads: 155 / 217
Version history: 1 change(s)
Referenced in: [show references]