开发者

Writing a file in binary or bytecode

开发者 https://www.devze.com 2023-04-04 05:05 出处:网络
I am storing large amounts of information inside of text files that are writte开发者_如何学运维n via java. I have two questions relating to this:

I am storing large amounts of information inside of text files that are writte开发者_如何学运维n via java. I have two questions relating to this:

  1. Is there any efficiency boost to writing in binary or bytecode over Strings?

  2. What would I use to write the data type into a file.

I already have a setup based around Strings, but I want to compare and at least know how to write the file in bytecode or binary.

When I read in the file, it will be translated into Strings again, but according to my reasearch if I write the file straight into bytecode it removes the added process on both ends of translating between Strings and code both for writing the file and for reading it.


cHao has a good point about just using Strings anyway, but I am still interested in the how if how to write varied data types in the file.

In other words, can I still use the FileReader and BufferedReader to read and translate back to Strings, or is there another thing to use. Also using a BinaryWriter, is it still just the FileWriter class that I use???


If you want to write it in "binary", and you want to save space, why not just zip it using the jdk? Meets all your requirements.

0

精彩评论

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