Java Integer to IP Address intToIpV4(int i)

Here you can find the source of intToIpV4(int i)

Description

int To Ip V

License

Open Source License

Declaration

public static String intToIpV4(int i) 

Method Source Code

//package com.java2s;
/*/*from  w ww. j  av a2 s.c o  m*/
    
Copyright (C) 2011 NTT DATA Corporation
    
This program is free software; you can redistribute it and/or
Modify it under the terms of the GNU General Public License
as published by the Free Software Foundation, version 2.
    
This program 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 General Public License for more details.
    
 */

public class Main {

    public static String intToIpV4(int i) {
        int b1 = (i >> 24) & 0xff;
        int b2 = (i >> 16) & 0xff;
        int b3 = (i >> 8) & 0xff;
        int b4 = i & 0xff;

        return b1 + "." + b2 + "." + b3 + "." + b4;
    }
}

Related

  1. intToIP(int ipAddr)
  2. intToIp(int ipInt)
  3. intToIpAddr(int ip)
  4. intToIpAddress(int i)
  5. intToIpString(int ip)
  6. intToIpV4String(int intIp)