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

17
LINES

< > BotCompany Repo | #1024270 // rotateStringBuffer

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

Libraryless. Click here for Pure Java version (1627L/11K).

1  
static void rotateStringBuffer(StringBuffer 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 #1024269

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: #1024270
Snippet name: rotateStringBuffer
Eternal ID of this version: #1024270/1
Text MD5: 0a391453dd18675b47f0835baf55d5e4
Transpilation MD5: c06bb15b34b9541f8b99c6db1752f38e
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:51:38
Source code size: 440 bytes / 17 lines
Pitched / IR pitched: No / No
Views / Downloads: 219 / 277
Referenced in: [show references]