String,int,char,byte[]数组的相互转换
2014-09-02 18:56
375 查看
1. String 转换为int
String str = "abc";
int data = Integer.parseInt(str);
或者
int data = Integer.valueOf(str);
2.int 型数据转换到String
int a = "3";
String str = Integer.valueOf(a).toString();
3.String 型数据转换为char型
String str = "abc";
char[] a = str.toCharArray();
4.char型转化为String型
char a ;
String str = Character.valueOf(a).toString();
5.String 型数据转换为byte[]数组
byte[] buf = new byte[1024];
String str = "abcd";
buf = str.getBytes()或者buf = str.getBytes("utf-8");
6.byte[]数组转换为String 型数据
byte[] buf = new byte[1024];
String str = new String(buf);
str= String.copyValueOf(str.toCharArray(), 0, buf.length]);
String str = "abc";
int data = Integer.parseInt(str);
或者
int data = Integer.valueOf(str);
2.int 型数据转换到String
int a = "3";
String str = Integer.valueOf(a).toString();
3.String 型数据转换为char型
String str = "abc";
char[] a = str.toCharArray();
4.char型转化为String型
char a ;
String str = Character.valueOf(a).toString();
5.String 型数据转换为byte[]数组
byte[] buf = new byte[1024];
String str = "abcd";
buf = str.getBytes()或者buf = str.getBytes("utf-8");
6.byte[]数组转换为String 型数据
byte[] buf = new byte[1024];
String str = new String(buf);
str= String.copyValueOf(str.toCharArray(), 0, buf.length]);
相关文章推荐
- int、char、double与byte相互转换的程序
- c# string和byte数组相互转换
- string,char,int类型的相互转换
- QString与string int char*的相互转换
- int、char、double与byte相互转换的程序
- Java中有关byte和String的转换笔记和byte[]到short、int、long的相互转换
- c#中 uint--byte[]--char[]--string相互转换汇总
- c#中 uint--byte[]--char[]--string相互转换汇总
- int、char、double与byte相互转换的程序
- int、char、double与byte相互转换的程序
- byte[]数组与string相互转换
- C#下byte数组与string的相互转换
- int、char、double与byte相互转换
- c#中 uint--byte[]--char[]--string相互转换汇总
- 【C#】c#中 uint--byte[]--char[]--string相互转换汇总
- c#中 uint--byte[]--char[]--string相互转换汇总
- c#中 uint--byte[]--char[]--string相互转换汇总
- int、char、double与byte相互转换的程序
- c#中 uint--byte[]--char[]--string相互转换汇总
- C# double float int string 与 byte数组 相互转化