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).

static void rotateStringBuffer(StringBuffer 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 #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: 215 / 270
Referenced in: [show references]