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

16
LINES

< > BotCompany Repo | #1033233 // regularLineBreaks

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

Libraryless. Click here for Pure Java version (3796L/22K).

1  
sS regularLineBreaks(int charsPerLine, S s) {
2  
  if (l(s) < charsPerLine) ret s;
3  
  
4  
  new StringBuilder buf;
5  
  int n = l(s), j = 0;
6  
7  
  for i to n: {
8  
    buf.append(s.charAt(i));
9  
    if (++j >= charsPerLine) {
10  
      buf.append('\n');
11  
      j = 0;
12  
    }
13  
  }
14  
  
15  
  ret str(buf);
16  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1033233
Snippet name: regularLineBreaks
Eternal ID of this version: #1033233/2
Text MD5: 1a5593e53b3511ddbe4d797927ad7955
Transpilation MD5: 1f8a3913b84bf088a68ad197601136b0
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-10-16 07:48:58
Source code size: 290 bytes / 16 lines
Pitched / IR pitched: No / No
Views / Downloads: 157 / 209
Version history: 1 change(s)
Referenced in: [show references]