开发者

Java: Question about data representation

I need to parse 70mb data with Ja开发者_运维知识库va and I've currently a xml document (1-level, no children), where each document has multiple fields.

I was wondering if I should replace it with a simpler text file in which each row is a doc, and the fields are comma separated.

Is this going to significantly improve performances ? And what if the I had, for instance, 4GB data instead ?

thanks


It would probably be more efficient to use the text file than the XML file if you ever get to a point where you can't fit the whole data set into memory at once. at that point, being able to parse the text file line by line would be better than the XML approach (which I believe loads the whole file into memory). According to a Robin Green XML only parses the whole file at once if you use DOM - SAX parsing streams.

There are other ways to persist data like this:
Database
Can this data be represented in a database? Java has easy support for most database systems, and you just have to install the right libraries to do so.

Java Properties
An alternative is the java properties system. This lets you put all your data on a file and then load them back and java parses the file when loading it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜