added int to ip
This commit is contained in:
parent
631d3a1fd8
commit
476b216713
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user