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);
I'd like this method to return a String of the Byte values. For example, it would be : "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);
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.