Tag: 序列化

从java写入.npy(numpy二进制格式)

有没有一个库在java中创建npy文件? 我正在寻找一种方法来写在Java中的大型矩阵,使用Python代码阅读。 npy似乎是一个不错的选择,因为它不会在python端添加额外的依赖关系,并且格式被记录下来。 我考虑过hdf5格式,但是对本地库的依赖使得部署更加困难。

如何将CORDA序列化的类型列入白名单

我希望能够将java.util.Date传递给模型java.util.Date的CORDA API端点 该模型 public final class Message{ public Date birthday; public Message(Date birthday) { this.birthday = birthday; } private Message() { // This is only here so the serializer can spin up a new instance. } public Date getBirthday() { return birthday; } } API @Path("foo") public final class FooApi { @PUT @Path("bar") @Produces(MediaType.APPLICATION_JSON) public […]

在android(kotlin)的内存中保存对象

我一直在尝试保存在Android的内部记忆列表,但我有一些问题。 这是我的代码保存和加载列表: 保存 saveStateList.add(saveState) val fos: FileOutputStream var oos: ObjectOutputStream? = null var allSaveStates :AllSaveStates = AllSaveStates() allSaveStates.saveStateList=saveStateList try { fos = activity.applicationContext.openFileOutput("saves", Context.MODE_PRIVATE) oos = ObjectOutputStream(fos) oos.writeObject(allSaveStates) oos.close() } catch (e: Exception) { } finally { if (oos != null) try { oos.close() } catch (e: Exception) { } } 载入中 val fis: FileInputStream […]

如何序列化/反序列化Kotlin中的自定义对象数组?

在我的Kotlin Android项目中,我做了一个扩展Serializable的FileItem类 class FileItem(<parameters>) : Serializable, Comparable<FileItem> { 所以我需要将这个类的实例序列化成一个Bundle val arguments:Bundle = Bundle() arguments.putSerializable("folders", folders as Serializable) 文件夹已被声明为: folders:Array<FileItem> (method parameter) 上面的序列化代码编译没有任何警告。 同时,当我需要反序列化文件夹项目时出现问题: val arguments: Bundle? = getArguments() if (arguments != null){ foldersItems = arguments.getSerializable("folders") as Array<FileItem> 其中foldersItems被声明为 var foldersItems: Array<FileItem>? 我得到以下警告,我不能设法解决没有suppress_warning注释 : w: <Path to my class>: (78, 28): Unchecked cast: java.io.Serializable! to kotlin.Array<com.loloof64.android.chess_positions_archiver.main_file_explorer.FileItem> […]

单身系列在Kotlin

我想知道是否有可能在Kotlin反序列化(恢复属性值)的声明对象, 而不必手动分配属性或采取反思 。 以下片段进一步解释: object Foo: Serializable { var propOne: String = "" // … fun persist() { serialize(this) // no problem with serialization } fun restore(bytes: ByteArray) { val fooObj: Foo = deserialize(bytes) as Foo // It seems Kotlin allows us to use singleton as type! // obvioulsly either of the following is wrong: […]