convert a java.net.InetAddress to a long
问题 I would like to convert a java.net.InetAddress and I fight with the signed / unsigned problems. Such a pain. I read convert from short to byte and viceversa in Java and Why byte b = (byte) 0xFF is equals to integer -1? And as a result came up with: final byte [] pumpeIPAddressRaw = java.net.InetAddress.getByName (pumpeIPAddressName).getAddress (); final long pumpeIPAddress = ((pumpeIPAddressRaw [0] & 0xFF) << (3*8)) + ((pumpeIPAddressRaw [1] & 0xFF) << (2*8)) + ((pumpeIPAddressRaw [2] & 0xFF)