简单说一下,&运算,两者都为1结果才是1,b>>4&0xf取出高四位,b&0x0f取出低四位,举个例子:
1、字节是 b = 1010 1111
2、b>>4 b = 00001010
3、b>>4&0x0f 也就是 00001010&00001111 —-> 1010高四位取出来了,取得低四位原理一样。后面的操作就是根据数据的大小转换一下格式,因为拿到的
数据是十进制的那么范围会在0-15之间,需要转换为16进制的0-f.
How do you encode a URL in Android?
I thought it was like this:
final String encodedURL = URLEncoder.encode(urlAsString, "UTF-8");
URL url = new URL(encodedURL);
If I do the above, the http:// in urlAsString is replaced by http%3A%2F%2F in encodedURL and then I get a java.net.MalformedURLException when I use the URL.
String uri = Uri.parse("http://...")
.buildUpon()
.appendQueryParameter("key", "val")
.build().toString();
Alternatively, you can use t doesn't throw checked exceptions.
Or use something like