【发布时间】:2016-09-24 15:32:18
【问题描述】:
我正在尝试获取/转换字节 [] 中 Arraylist 的值 下面是我的代码
final ArrayList<Object> imglists = new ArrayList<Object>();
这是我在这个数组列表中的对象数组列表 m 以字节的形式存储图像的值
for (int i=0; i<mPlaylistVideos.size();i++) {
holder.mThumbnailImage.buildDrawingCache();
Bitmap bitmap= holder.mThumbnailImage.getDrawingCache();
ByteArrayOutputStream bs = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 50, bs);
byte[] rough = bs.toByteArray();
imglists.add(i,rough);
}
我正在尝试从 arraylist 中获取特定值并将其存储在 byte[] 这就是我想做的事情
byte[] value=imglists.get(2);
我找不到将 Arraylist of Object 转换为 byte[] 的完整答案 我知道 Arraylist 不支持原始数据类型(即字节)
【问题讨论】:
-
你想要 ArrayLIst of byte[]?
-
为什么不定义 ArrayList
而不是 ArrayList -
Java 对象是可序列化的。您可以将对象转换为字符串,然后将其转换为字节[]。
-
@DeendayalGarg nop 我不想要字节数组列表的数组列表不支持字节[]。我只想将 Arraylist
-
@AmmY 转换成字符串很好,但是当我将它转换回 byte[] 值时不匹配