Hey, I got college project, and in project I have about 1000 questions for user, where could I store them? Like can I store them in array or some kind of database? My group of 10 people will have to type out all questions so I was wondering is there any easy way to do this?
P.S - the reason I created new thread is because that "What you need help with" is useless, I asked same question there no replies.
Store the questions in a text file, one per line, then read them on program startup.
text file, xml file, or a simple database with SQLite
[QUOTE=kaukassus;34942536]text file, xml file, or a simple database with SQLite[/QUOTE]
I don't know if there are any good XML libraries for Java, but I've found that JSON's Java distribution works quite well.
As for storage within the program itself, I would write a Question class that holds all data/methods that pertains to a question and then store them in an array or similar fast-access container.
a md5 hashed xml inside a gzipped tarball would fit for that
^or a .txt
[QUOTE=ichiman94;34943473]a md5 hashed xml inside a gzipped tarball would fit for that[/QUOTE]
You should get a job in show business, you're great at technobabble.
You could use [b]DataInputStream[/b] and [b]DataOutputStream[/b] to read/write them to file.
[code]
FileInputStream fileStream = new FileInputStream("hello.dat");
DataInputStream dataStream = new DataInputStream(fileStream);
//read the string
String question = dataStream.readUTF();
//close
fileStream.close();
dataStream.close();
[/code]
...and to write to file:
[code]
FileOutputStream fileStream = new FileOutputStream("hello.dat");
DataOutputStream dataStream = new DataOutputStream(fileStream);
//write the string
fileStream.writeUTF("question");
//close
fileStream.close();
dataStream.close();
[/code]
To store them to memory, you could either use an array or ArrayList.
Hope this helps.
Sorry, you need to Log In to post a reply to this thread.