4 Replies - 243 Views - Last Post: 15 November 2012 - 11:56 AM Rate Topic: -----

#1 mon_e_mons  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 05-October 12

Im trying to read records one at a time from a file without delimiters

Posted 15 November 2012 - 10:53 AM

I'm making a program for class that is supposed to write one word at a time to a text file and append it to whatever is there. It writes the file with no delimiters or new lines or capitalization. So if you entered "apple" and then entered "orange" and then "banana" the file will read "appleorangebanana". The program also has a read button that is supposed to read one word at a time and put it in a text field. How do you make the program figure out where apple ends and orange begins? I'm also not allowed to write a separate index file. This seems impossible to me but supposedly people have figured this out before.

Is This A Good Question/Topic? 0
  • +

Replies To: Im trying to read records one at a time from a file without delimiters

#2 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 4307
  • View blog
  • Posts: 12,088
  • Joined: 18-April 07

Re: Im trying to read records one at a time from a file without delimiters

Posted 15 November 2012 - 11:16 AM

Well there is only two ways you can know what is the beginning verses the end of each "token". You either have to insert a delimiter like a space (which sounds like what they want you to do) or keep track of the length of each token... for instance inserting "apple" and then storing "5" somewhere so when you read you know to read 5 characters.

So you might be missing an important detail somewhere.
Was This Post Helpful? 1
  • +
  • -

#3 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8324
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Im trying to read records one at a time from a file without delimiters

Posted 15 November 2012 - 11:41 AM

You can write as a byte 5 than as bytes a p p l e
then as a byte 6 then as bytes o r a n g e
or use " ", "," "\t", "|", "/", ... as delimiters
Was This Post Helpful? 0
  • +
  • -

#4 g00se  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 2641
  • View blog
  • Posts: 11,157
  • Joined: 20-September 08

Re: Im trying to read records one at a time from a file without delimiters

Posted 15 November 2012 - 11:47 AM

Quote

How do you make the program figure out where apple ends and orange begins? I'm also not allowed to write a separate index file. This seems impossible to me but supposedly people have figured this out before.
I thought we'd been through this? It's not possible (short of checking in a dictionary)
Was This Post Helpful? 1
  • +
  • -

#5 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8324
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Im trying to read records one at a time from a file without delimiters

Posted 15 November 2012 - 11:56 AM

Yes we went throug this. Thanks g00se
http://www.dreaminco...1&#entry1746723

Please avoid double posting, you are wasting our time
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1