簡體   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