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

17
LINES

< > BotCompany Repo | #1024269 // rotateStringBuilder

JavaX fragment (include)

1  
static void rotateStringBuilder(StringBuilder buf, int max) ctex {
2  
  if (buf == null) ret;
3  
  synchronized(buf) {
4  
    if (buf.length() <= max) ret;
5  
    
6  
    try {
7  
      int newLength = max/2;
8  
      int ofs = buf.length()-newLength;
9  
      S newString = buf.substring(ofs);
10  
      buf.setLength(0);
11  
      buf.append("[...] ").append(newString);
12  
    } catch (Exception e) {
13  
      buf.setLength(0);
14  
    }
15  
    buf.trimToSize();
16  
  }
17  
}

Author comment

Began life as a copy of #1016424

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1024269
Snippet name: rotateStringBuilder
Eternal ID of this version: #1024269/3
Text MD5: 1b56a359ee738c0e05428120dd2a9a64
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-07-28 23:50:22
Source code size: 442 bytes / 17 lines
Pitched / IR pitched: No / No
Views / Downloads: 286 / 348
Version history: 2 change(s)
Referenced in: [show references]