views:

142

answers:

5

I'm looking for some information and a little history. I am writing a program and I want to save some data without using a database. I'm assuming I could use XML but what else can I use? How do you save data to files and then retrieve them without XML and without plain text? What is Binary formatting, can that be used? Isn't binary formatting what Microsoft used to use for Office files? I am unsure about how to go about this, and would appreciate any help, thanks.

+1  A: 

What kind of data are you trying to save? And is there a reason to avoid plain text, XML, and databases? I can understand avoiding databases, as you may not want to deal with the overhead, and if you are referring to saving information akin to a Word file, then it doesn't make much sense to use anything other than a flat file (unless you're working on a web application, in which case I take back that statement).

What development platform are you using? In Java, you can use a FileReader and FileWriter to read and write files. If you want to format your files before creating them, you can write a method to do that. Other languages will have similar functionality, just do a search on "reading and writing files in languageX".

Elie
A: 

"Binary formatting" is a pretty vague term. Basically it's "anything other than plain text formatting."

You can pick whatever format you want to write your data to disk. If you use an existing format (XML, ini-file, Protocol Buffers, Thrift etc) you benefit from there already being code to write/parse the data. If you write your own custom format, you can tailor it to your exact requirements.

This issue was discussed in another question.

Jon Skeet
+2  A: 

Why avoid a database? If it is simply the overhead, have you considered sqlite?

chills42
A: 

I am using C#. I am probably going to use XML but I am just learning and I wanted to know some alternatives. Basically, I wanted my program to be similar to a program like Office, where you add something and then save it to a file for future retrieval. If you were to look at the Office file in a text editor, it would be all garbled and I think it's binary. When you retrieve the file then, would it just be pulling in the info and saving it to a collection or something?

jumbojs
A: 

Blockquote "Binary formatting" is a pretty vague term. Basically it's "anything other than plain text formatting." You can pick whatever format you want to write your data to disk. If you use an existing format (XML, ini-file, Protocol Buffers, Thrift etc) you benefit from there already being code to write/parse the data. If you write your own custom format, you can tailor it to your exact requirements.

Interesting, so that's what I was thinking. There are already existing formats like obviously XML,but you can also use others or create your own. Do you happen to know what was commonly used before XML or do most big companies just write their own? I am assuming it's very difficult to write your own

jumbojs