ip Int To String - Java java.lang

Java examples for java.lang:int Format

Description

ip Int To String

Demo Code

//package com.java2s;

public class Main {
    public static void main(String[] argv) {
        int ip = 4223;
        System.out.println(ipIntToString(ip));
    }//  w w  w . j  av  a 2  s .  co  m

    public static String ipIntToString(int ip) {
        // @formatter:off
        return String.format("%d.%d.%d.%d", (ip & 0xff), (ip >> 8 & 0xff),
                (ip >> 16 & 0xff), (ip >> 24 & 0xff));
        // @formatter:on
    }
}

Related Tutorials