WIFI IP转换
private String intToIp(int i) { /** * " -- 表示双引号(") * & -- 表示位与运算符(&) * < -- 表示小于运算符(<) * > -- 表示大于运算符(>) * -- 表示空格( ) */ return ( i & 0xFF) + "." + ((i >> 8 ) & 0xFF) + "." + ((i >> 16 ) & 0xFF) + "." + ((i >> 24 ) & 0xFF) ; }
由于int是32位,和0xff相与后,高24比特就会被清0。
Integral Types and Values The values of the integral types are integers in the following ranges:
* For byte, from -128 to 127, inclusive
* For short, from -32768 to 32767, inclusive
* For int, from -2147483648 to 2147483647, inclusive
* For long, from -9223372036854775808 to 9223372036854775807, inclusive
* For char, from '\u0000' to '\uffff' inclusive, that is, from 0 to 65535