Working with files

From Computer Science Wiki
Revision as of 11:56, 5 January 2020 by Mr. MacKenty (talk | contribs)
Object-Oriented Programming[1]

We use files to store data. For example let us imagine you have a program that functions as a store inventory system. The program allows you to create, update, read and delete items from a store inventory. If you have no way of saving changes you've made, when you re-start your program, you will need to make all those changes again.

File I/O is the process of reading from a file and writing to a file'. These don't happen at the same time (you can't read from a file and write to the same file at the same time).

Some programs only use files to create, read, update and delete data. For example, if we had a program which managed store inventory, every time you made a change (creating a new item, reading an item, updating something about an item, deleting an item) a file would be updated. The advantage of this method is in the event of unexpected power loss, your data would be very safe. The disadvantage of this method is your program would be much slower and files can be corrupted.

Some programs use internal data structures and then at certain moments save or read that data to a file. For example, if we had a program which managed store inventory, when we started our program the program would read the inventory from a file and



File input / output

File formats

XML

JSON

Plain Text

Helpful Links

References