Java Integer to IP Address intToIp(int i)

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

Description

int To Ip

License

Apache License

Declaration

static String intToIp(int i) 

Method Source Code

//package com.java2s;
/*/*ww w .  jav a 2 s  .c  om*/
 * Copyright 2012 The Netty Project
 *
 * The Netty Project licenses this file to you under the Apache License,
 * version 2.0 (the "License"); you may not use this file except in compliance
 * with the License. You may obtain a copy of the License at:
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */

public class Main {
    private static final int SECOND_ADDRESS_OCTET_SHIFT = 16;
    private static final int FIRST_ADDRESS_OCTET_SHIFT = 24;
    private static final int THIRD_ADDRESS_OCTET_SHIFT = 8;
    private static final int XOR_DEFAULT_VALUE = 0xff;

    static String intToIp(int i) {
        return String.valueOf(i >> FIRST_ADDRESS_OCTET_SHIFT & XOR_DEFAULT_VALUE) + '.'
                + (i >> SECOND_ADDRESS_OCTET_SHIFT & XOR_DEFAULT_VALUE) + '.'
                + (i >> THIRD_ADDRESS_OCTET_SHIFT & XOR_DEFAULT_VALUE) + '.' + (i & XOR_DEFAULT_VALUE);
    }
}

Related

  1. Int2Ip(long ip)
  2. int2IpAddressString(long i)
  3. int2ipstr(int addr)
  4. int2IpStr(long ip)
  5. intToIp(int address)
  6. intToIp(int i)
  7. intToIp(int i)
  8. intToIP(int intIP)
  9. intToIp(int ip)