繁体   English   中英

将字节数组转换为字符串--与Performace Android

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM