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

24
LINES

< > BotCompany Repo | #1008736 // IP to country simplified

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Uses 51K of libraries. Click here for Pure Java version (3855L/26K/84K).

!7

static new TreeMap<Long, S> data;

p {
  for (S s : lines(readerToString(utf8bufferedReader(lzmaInputStream(#1004343))))) {
    L<S> l = tok_splitAtComma_unquote(s);
    if (l(l) < 3) continue;
    long start = parseLong(first(l));
    long end = parseLong(second(l));
    S country = intern(l.get(4));
    data.put(start, country);
  }
  print(l(data) + " " + first(keys(data)));
  botSleep();
}

answer {
  long ip = ipToInt(trim(s));
  print("s=" + s + ", ip=" + ip);
  Long key = data.floorKey(ip);
  if (key != null)
    try answer data.get(key);
}

Author comment

Began life as a copy of #1008728

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1008736
Snippet name: IP to country simplified
Eternal ID of this version: #1008736/1
Text MD5: e19ae74eef2506db4c8560235836a7f3
Transpilation MD5: c5139ec9a677bc00164fae0ec8060796
Author: stefan
Category: javax
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-05-31 02:05:23
Source code size: 580 bytes / 24 lines
Pitched / IR pitched: No / No
Views / Downloads: 467 / 517
Referenced in: [show references]