home / blog

Tag Archives: WTF

Convert dotted IP to decimal IP – my comedy answer

String input = “134.115.64.1”; String sum = input.replaceAll(“(\\d+)\\.(\\d+)\\.(\\d+)\\.(\\d+)”, “($1 * 16777216) + ($2 * 65536) + ($3 * 256) + $4”); ScriptEngineManager mgr = new ScriptEngineManager(); ScriptEngine engine = mgr.getEngineByName(“JavaScript”); double result = (Double) engine.eval(sum); System.out.println((long) result);

Posted in geek | Tagged , | Leave a comment