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

16
LINES

< > BotCompany Repo | #1032716 // HostAndPort

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

Libraryless. Click here for Pure Java version (3935L/23K).

srecord HostAndPort(S host, int port) {
  *(S s) {
    int i = indexOf(s, ':');
    if (i < 0)
      host = s;
    else {
      host = takeFirst(i, s);
      port = parseInt(dropFirst(i+1, s));
    }
  }
  
  toString {
    //ret host + (port == 0 ? "" : ":" + port);
    ret host + ":" + port;
  }
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1032716
Snippet name: HostAndPort
Eternal ID of this version: #1032716/7
Text MD5: 0c9e3bf32fbb1cc2d54851ab48bc26fe
Transpilation MD5: b1947adb2cb98d4c94add74ecec03682
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-10-03 19:17:59
Source code size: 315 bytes / 16 lines
Pitched / IR pitched: No / No
Views / Downloads: 107 / 211
Version history: 6 change(s)
Referenced in: [show references]