Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I use a text file or Database?

Tags:

java

database

So I'm putting together an RSS parser which will process an RSS feed, filter it, and then download the matched items. Assume that the files being downloaded are legal torrent files.

Now I need to keep a record of the files that I have already downloaded, so they aren't done again.

I've already got it working with SQLite (create database if not exists, insert row if a select statement returns nothing), but the resulting jar file is 2.5MB+ (due to the sqlite libs).

I'm thinking that if I use a text file, I could cut down the jar file to a few hundred kilobytes.

I could keep a list of the names of files downloaded - one per line - and reading the whole file into memory, search if a file exists, etc.

The few questions that occur to me know:

  • Say if 10 files are downloaded a day, would the text file method end up taking too much resources?
  • Overall which one is faster

Anyway, what do you guys think? I could use some advice here, as I'm still new to programming and doing this as a hobby thing :)

like image 963
Amir Avatar asked Jan 01 '12 09:01

Amir


1 Answers

If you need to keep track only of few informations (like name of the file), you can for sure use a simple text file.

Using a BufferedReader to read you should achieve good performance.

like image 90
aleroot Avatar answered Oct 13 '22 14:10

aleroot