There was a bug in the previous implementation due to byte to int conversion. An ip with number higher then 127 had negative numbers.

@oliviertoupin Any reason you used getAddress and then format? or if getHostAddress is ok?