String and Byte
来源:互联网 发布:阿里云快照功能 编辑:程序博客网 时间:2024/04/29 04:10
http://zhangyuefeng1983.blog.163.com/blog/static/1083372520126693524870/
1.string 转 byte[]
1、字节数组转换为字符串
byte[] byBuffer = new byte[20];
... ...
String strRead = new String(byBuffer);
strRead = String.copyValueOf(strRead.toCharArray(), 0, byBuffer.length]);
2、字符串转换成字节数组
byte[] byBuffer = new byte[200];
String strInput="abcdefg";
byBuffer= strInput.getBytes();
注意:如果字符串里面含有中文,要特别注意,在android系统下,默认是UTF8编码,一个中文字符相当于3个字节,只有gb2312下一个中文相当于2字节。这种情况下可采取以下办法:
byte[] byBuffer = new byte[200];
String strInput="我是字符串";
byBuffer= strInput.getBytes("gb2312");
int beginIndex = 0;
byte[] ch = line.getBytes(def.getEncode());
for(int a =0; a < clmSizeList.size(); a++){
int length = clmSizeList.get(a);
clmDataAry[a] = new String(ch, beginIndex, length);
beginIndex = beginIndex + length;
}
- string and byte[] converter
- String and Byte
- c# - string to byte[] and vice versa
- String(byte bytes[], String charsetName)
- byte to string
- byte转为string
- byte[]转String
- C# string to byte[]
- byte[] 与 string
- string byte[]的转换
- C# String byte[] 互转
- byte转为string
- string 互换 byte[]
- C# string byte[] 转换
- byte[] 转 String 笔录
- string int byte转换
- byte,char,String
- byte转String
- URLConnection和HTTPClient的比较
- JLPT三级语法桌面(75条语法)
- 设计模式C++学习笔记之二(Proxy代理模式)
- RingtonePreference
- 在 Tomcat 上配置虚拟主机
- String and Byte
- Redis java demo
- iOS 推送 证书申请 本地推送
- 工厂模式笔记(转)
- 设计模式C++学习笔记之三(Singleton单例模式)
- 2014,念念不忘 必有回响
- 欢迎使用CSDN-markdown编辑器
- LeetCode:Insertion Sort List
- 设计模式学习笔记---职责链模式chain of responsibility(Java版)