字节数组转换为字符串 - - 随着服务表现的Android [英] Convert byte array to a string - - With Performace Android
本文介绍了字节数组转换为字符串 - - 随着服务表现的Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Bitmap foto = b.getBitmap();
byte[] bytes = null;
ByteArrayOutputStream ba = new ByteArrayOutputStream();
foto.compress(Bitmap.CompressFormat.JPEG, 100, ba);
foto.recycle();
foto = null;
bytes = ba.toByteArray();
String bBytes = Arrays.toString(bytes);
我想这个方法返回字节值的字符串。例如,这将是:12,23,34 ......
推荐答案
下面是你如何能做到这一点。
Here is how you can do it.
import java.util.Arrays;
public class Test {
public static void main(String[] args) {
byte[] bytes = {1,2,3,12};
String bBytes = Arrays.toString(bytes);
bBytes = bBytes.replaceAll(" ", "");
bBytes = bBytes.replaceAll("\\[", "");
bBytes = bBytes.replaceAll("\\]", "");
System.out.println(bBytes);
}
}
这篇关于字节数组转换为字符串 - - 随着服务表现的Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文