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

8
LINES

< > BotCompany Repo | #1026403 // renameFileBaseName - rename file, keep extension

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

Libraryless. Click here for Pure Java version (2210L/14K).

1  
static File renameFileBaseName(File f, S newBaseName) {
2  
  S ext = fileExtension(f);
3  
  S base = dropSuffix(ext, fileName(f));
4  
  File f2 = fileInSameDir(f, newBaseName + ext);
5  
  if (eq(f, f2)) ret f;
6  
  if (!renameFile(f, f2)) null;
7  
  ret f2;
8  
}

Author comment

Began life as a copy of #1002706

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1026403
Snippet name: renameFileBaseName - rename file, keep extension
Eternal ID of this version: #1026403/5
Text MD5: 9f907c292ce0e80a51a34996c3692bed
Transpilation MD5: 91ffea045070b34b9f0bee6cef71bb43
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-01-02 14:22:29
Source code size: 248 bytes / 8 lines
Pitched / IR pitched: No / No
Views / Downloads: 187 / 301
Version history: 4 change(s)
Referenced in: [show references]