added int to ip

This commit is contained in:
snoop 2017-08-23 16:21:47 +09:00
parent 631d3a1fd8
commit 476b216713
2 changed files with 32 additions and 0 deletions

View File

@ -0,0 +1,15 @@
package com.loafle.overflow.commons.utils;
/**
* Created by snoop on 17. 8. 23.
*/
public class StringConvertor {
public static String intToIp(long i) {
return ((i >> 24 ) & 0xFF) + "." +
((i >> 16 ) & 0xFF) + "." +
((i >> 8 ) & 0xFF) + "." +
( i & 0xFF);
}
}

View File

@ -0,0 +1,17 @@
package com.loafle.overflow.commons.utils;
import org.junit.Test;
/**
* Created by snoop on 17. 8. 23.
*/
public class StringConvertorTest {
@Test
public void intToIp() throws Exception {
String ipStr = StringConvertor.intToIp(3232235797L);
System.out.println(ipStr);
}
}