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

16
LINES

< > BotCompany Repo | #1033459 // regularSpecialLineBreaks

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

Libraryless. Click here for Pure Java version (4532L/25K).

sS regularSpecialLineBreaks(int charsPerLine, S lineBreak, S s) {
  if (l(s) < charsPerLine) ret s;
  
  new StringBuilder buf;
  int n = l(s), j = 0;

  for i to n: {
    buf.append(s.charAt(i));
    if (++j >= charsPerLine) {
      buf.append(lineBreak);
      j = 0;
    }
  }
  
  ret str(buf);
}

Author comment

Began life as a copy of #1033233

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1033459
Snippet name: regularSpecialLineBreaks
Eternal ID of this version: #1033459/1
Text MD5: 8d75d864ef22de678764189e97ca9705
Transpilation MD5: 23ac0fa1e8976233e318907e8e001ce2
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-10-28 21:11:54
Source code size: 315 bytes / 16 lines
Pitched / IR pitched: No / No
Views / Downloads: 83 / 124
Referenced in: [show references]