[英]Convert byte array to a string - - With Performace 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);
我想要此方法返回Byte值的字符串。 例如,它將是: "12,23,34 ...."
。
這是您的操作方法。
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);
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.