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

5
LINES

< > BotCompany Repo | #1037261 // shortenToFirstAndLast

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

Libraryless. Click here for Pure Java version (730L/4K).

sS shortenToFirstAndLast(int chars, S s) {
  if (s == null) ret "";
  ret s.length() <= chars*2 ? s
    : takeFirst(chars, s) + "..." + takeLast(chars, s);
}

Author comment

Began life as a copy of #1000644

download  show line numbers  debug dex  old transpilations   

Travelled to 2 computer(s): gjtlkbvenryc, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1037261
Snippet name: shortenToFirstAndLast
Eternal ID of this version: #1037261/1
Text MD5: eca3d48ab78180d734f3671c52c0cacb
Transpilation MD5: 9d307bf140be05c2c70bf0c775842947
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2023-10-22 16:08:35
Source code size: 163 bytes / 5 lines
Pitched / IR pitched: No / No
Views / Downloads: 147 / 204
Referenced in: [show references]