• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Reading strings from a line problem _ any help!!

 
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

My test main class allows user input to create one integer, which I've converted to a string, plus four strings representing details to be written to a file. When these details are written to the file they initially read correctly, eg:


111,hello one,hello two,hello three,hello four



The problem occurs when I try to write a second set if user entry values to this file. It is expecting four strings as words, and therefore reads and writes the above line as follows,


111,,hello,one,hello,two,hello,three,hello



I have absolutely no idea why this is happening and would really appreciate some help or advice with this problem.

The current code for my test main class is as follows,


Any help or advice really appreciated at this stage!!
 
Ranch Hand
Posts: 1970
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is rather difficult to give a good reply, because your code is based on the classes like TitleList, SimpleReader and SimpleWriter, which are not part of standard Java.

Guessing at what SimpleReader and SimpleWriter are trying to do, I cannot see anything immediately wrong with your code. However, something must be wrong if you are seeing wrong behaviour, so we would need to see exactly what these other classes do. That might be too much code to post, though.
 
celine scarlett
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Thanks for the reply. SimpleReader and Writer allow basic reading in and out of files etc. My current code for the TitleList class is as follows,



The above class also uses the basic Title class which is as follows,


Can anybody see why this problem is occurring?

Any help gratefully appreciated!
 
Something about .... going for a swim. With this tiny ad ...
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic