stringcharbyteslength
来源:互联网 发布:linux删除多个文件命令 编辑:程序博客网 时间:2024/06/05 15:45
package TestDemo.test;
import java.io.UnsupportedEncodingException;
public class TestStrByte{
public static void main(String[] args){
String str=”中”;
char x = ‘中’;
byte[] bytes = null;
byte[] bytes1 = null;
try{
bytes = str.getBytes(“utf-8”);
bytes1= charToByte(x);
}catch(UnsupportedEncodingException e){e.printStackTrace();}
System.out.println(bytes.length);
System.out.println(bytes1.length);
}
public static byte[] charToByte(char c){
byte[]b=new byte[2];
b[0]=(byte)((c&0xFF00)>>8);
b[1]=(byte)(c&0xFF);
return b;
}
}
阅读全文
0 0
- stringcharbyteslength
- 微信上传网络图片到临时素材
- CentOS7使用firewalld打开关闭防火墙与端口
- 小学生到底要不要学奥数 学奥数的利弊分析!
- Win2008 r2+oracle rac 11.2.01+starwind 安装手册
- Asteroids!(bfs)
- stringcharbyteslength
- 【BZOJ4034】树上操作(HAOI2015)-树链剖分
- HORNER(霍纳)法则的C实现以及算法比较 2.10
- ViewGroup事件分发
- java编译中可能遇到的问题
- Ubuntu Server 16.04 安装tomcat8
- Tair java c++客户端配置使用
- Juery新增节点之后事件绑定无效
- get_brand_wcpay_request:fail,微信公众号支付的那点坑