Here you can find the source of convertIpv4AddressToString(byte[] ipv4Address)
public static String convertIpv4AddressToString(byte[] ipv4Address)
//package com.java2s; /*//ww w. j a va 2 s . co m * lib-bitcoinj * Copyright (c) 2014, Stephen Liang, All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Affero General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public * License along with this library. */ public class Main { public static String convertIpv4AddressToString(byte[] ipv4Address) { if (ipv4Address.length != 4) { throw new IllegalArgumentException( "The input is too large, it must be of size 4. " + "The size is " + ipv4Address.length); } StringBuilder sb = new StringBuilder(""); for (int i = 0; i < ipv4Address.length; i++) { int currentOctet = ipv4Address[i] & 0xFF; sb.append(currentOctet); if (i != 3) { sb.append("."); } } return sb.toString(); } }