Java snippet configuration

Hello guys,

can I ask you for some small help?

I deal with one Java snippet configuration and I am not clear of it.

Let’s have an example of one input column from table creator called ipv6 full of ipv6 addresses.

The task is recalculate them into number. For ip4 the task is easy, but how to deal with ipv6?

I found one java code which should be able do that, but I don\t know how to configure Java snippet with it.

Thank you in advance!

Code is here:

java.math.BigInteger Dot2LongIP(String ipv6) {
	java.net.InetAddress ia = java.net.InetAddress.getByName(ipv6);
	byte byteArr[] = ia.getAddress();

	if (ia instanceof java.net.Inet6Address) {
		java.math.BigInteger ipnumber = new java.math.BigInteger(1, byteArr);
		return ipnumber;
	}
}

Screen here:

If you click on the little + boxes to expand the collapsed code, you’ll see the problem - you’re putting this method outside of the class. (Also, since you’re importing all of java.math and java.net - you don’t need to reference those classes in your method by their full path.)

3 Likes

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.