public static String List2String(List SceneList) throws IOException {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream);
objectOutputStream.writeObject(SceneList);
String SceneListString = new String(Base64.encode(byteArrayOutputStream.toByteArray(), Base64.DEFAULT));
objectOutputStream.close();
return SceneListString;
}
@SuppressWarnings("unchecked")
public static List String2List(String SceneListString) throws StreamCorruptedException, IOException, ClassNotFoundException {
byte[] mobileBytes = Base64.decode(SceneListString.getBytes(), Base64.DEFAULT);
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(mobileBytes);
ObjectInputStream objectInputStream = new ObjectInputStream(byteArrayInputStream);
List SceneList = (List) objectInputStream.readObject();
objectInputStream.close();
return SceneList;
}
Android 使用Preferences保存List<E>
最新推荐文章于 2024-04-06 17:40:17 发布