速度:Java序列化还是csv? [英] Speed: Java serialization or csv?

查看:95
本文介绍了速度:Java序列化还是csv?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有各种各样的Java简单结构(仅由原始成员组成),我需要将它们保存并加载到文件中

I have a large array of Java simple structs (consists of just primitive members) and I need to save and load them from and to a file


  • 实现 java.io.Serializable 并使用 read / writeObject < b>或

  • 覆盖 toString() / toCSV(),添加新的构造函数并对其进行读写文本文件?

  • implementing java.io.Serializable and using read/writeObject or
  • overriding toString() / toCSV(), adding a new constructor and reading/writing to text file?




我想在此阶段避免二进制流。



I want to avoid binary stream at this stage.

推荐答案

序列化通常更快。读回文件时,您可以节省手动分析文件的时间。但是,随着时间的推移和程序的不同实现,CSV方法将更加灵活。

Serialization is usually faster. You save time parsing the file manually when reading it back in. However, the CSV approach would be more flexible over time and different implementations of your program.

这篇关于速度:Java序列化还是csv?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆