首页 > 技术文章 > byte[] 与字符串转换

heling 2014-11-04 01:52 原文

//取值之后进行
StringBuffer buffer=new StringBuffer();
for (int i = 0; i < enBytes.length; i++)
{
if(i!=0)
{
buffer.append(",");
}
buffer.append(enBytes[i]);
}
System.out.println("加密后的密文:" + buffer.toString());

String[] temp=buffer.toString().split(",");
byte[] b = new byte[temp.length];
for (int i = 0; i < temp.length; i++)
{
b[i] = Byte.parseByte(temp[i]);
}
String s1 = new String(enBytes);

推荐阅读