Results 1 to 5 of 5
  1. #1
    eevaa is offline Member
    Join Date
    May 2010
    Posts
    4
    Rep Power
    0

    Arrow 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!

  2. #2
    gcalvin is offline Senior Member
    Join Date
    Mar 2010
    Posts
    953
    Rep Power
    5

    Default

    You're probably better off using a database for this. Otherwise, you're re-inventing the wheel.

    -Gary-

  3. #3
    StormyWaters is offline Senior Member
    Join Date
    Feb 2009
    Posts
    305
    Rep Power
    6

    Default

    You might be able to get away with a Properties file. Properties (The Java™ Tutorials > Essential Classes > The Platform Environment)

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,403
    Rep Power
    25

    Default

    a way to read parts of a file by index
    Does that mean that each section of the file starts at line whose number would be in a separate file?
    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.

  5. #5
    eevaa is offline Member
    Join Date
    May 2010
    Posts
    4
    Rep Power
    0

    Default

    Ookay, the database thing sound great. I'll have a look at how to work with databases. Also, using properties might be really really useful. Thank's alot!

Similar Threads

  1. Replies: 9
    Last Post: 10-20-2009, 10:52 AM
  2. Replies: 3
    Last Post: 05-09-2009, 11:31 PM
  3. Reading XML from file
    By chriscant in forum New To Java
    Replies: 0
    Last Post: 03-17-2009, 01:34 PM
  4. Reading a doc file
    By thehero in forum Advanced Java
    Replies: 0
    Last Post: 03-15-2009, 06:48 AM
  5. Help for reading a doc file
    By thehero in forum New To Java
    Replies: 1
    Last Post: 02-24-2009, 06:44 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •