Results 1 to 5 of 5
Thread: Reading from File
- 05-21-2010, 08:14 PM #1
Member
- Join Date
- May 2010
- Posts
- 4
- Rep Power
- 0
Reading from File
Hey everyone! :)
I am trying to program a brief text adventure just for getting used to Java. Now what I want to do is: I've got large quantities of text outputs (descriptions, dialogues and so on), so I don't want to put all that text into my Java files. Of course what I first thought of is reading from a text file, but then I would need to know how to read only parts of the file. But only reading certain lines would make later changes to the text file almost impossible cause then I'd also have to change the line numbers everywhere. Now I am looking for a way to read parts of a file by index. Does anyone know a proper way of doing so? I've also thought of XML but I don't know if that would work and reading those files seems rather complicated...
I'd be really thankful for your help!
- 05-21-2010, 08:16 PM #2
Senior Member
- Join Date
- Mar 2010
- Posts
- 952
- Rep Power
- 11
You're probably better off using a database for this. Otherwise, you're re-inventing the wheel.
-Gary-
- 05-21-2010, 09:09 PM #3
Senior Member
- Join Date
- Feb 2009
- Posts
- 312
- Rep Power
- 13
You might be able to get away with a Properties file. Properties (The Java™ Tutorials > Essential Classes > The Platform Environment)
- 05-21-2010, 10:07 PM #4a way to read parts of a file by index
Could you break the data up into separate files for each section and use naming conventions to define the sections. The files could be put into a jar/zip file to only have a single physical file to deal with.
- 05-22-2010, 09:18 AM #5
Member
- Join Date
- May 2010
- Posts
- 4
- Rep Power
- 0
Similar Threads
-
Reading and Writing the contents of a file to another file
By priyankatxs in forum New To JavaReplies: 9Last Post: 10-20-2009, 11:52 AM -
[SOLVED] how to reading binary file and writing txt file
By tOpach in forum New To JavaReplies: 3Last Post: 05-10-2009, 12:31 AM -
Reading XML from file
By chriscant in forum New To JavaReplies: 0Last Post: 03-17-2009, 02:34 PM -
Reading a doc file
By thehero in forum Advanced JavaReplies: 0Last Post: 03-15-2009, 07:48 AM -
Help for reading a doc file
By thehero in forum New To JavaReplies: 1Last Post: 02-24-2009, 07:44 AM
Bookmarks