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

17
LINES

< > BotCompany Repo | #1024269 // rotateStringBuilder

JavaX fragment (include)

static void rotateStringBuilder(StringBuilder buf, int max) ctex {
  if (buf == null) ret;
  synchronized(buf) {
    if (buf.length() <= max) ret;
    
    try {
      int newLength = max/2;
      int ofs = buf.length()-newLength;
      S newString = buf.substring(ofs);
      buf.setLength(0);
      buf.append("[...] ").append(newString);
    } catch (Exception e) {
      buf.setLength(0);
    }
    buf.trimToSize();
  }
}

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: 211 / 268
Version history: 2 change(s)
Referenced in: [show references]