• 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
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

error in retrieving from file.

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


tha actual contents of the file is

business
personal

but my output is

THE CONTENTS FROM FILE IS:usiness
THE CONTENTS FROM FILE IS:personal

so that when i enter business it doesn't go in to the loop which checks for equality.

please help.


 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The first character is eaten by the "check=reader1.read()" statement. I don't think you need that anyway - you can check the file for being empty via "myF.length() == 0".
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Look at the Javadocs for BufferedReader's read() method: what do you expect to happen?
 
gayathri murugesan
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i would like to retrieve the contents from folderwithmsg.txt file and then compare with the fileName given by user.if the filename is not present in the text file,i should write in the text file.otherwise i should not.as the first character is being omitted,whenever the filename equals the first name in the text file ,it is writing in the file.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You were already told why the first character is being read, given a link to the documentation to prove it, and provided a workaround--what else do you need?
 
gayathri murugesan
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
with length method also i m getting the same type of problem.

 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


I think you should take a step back and re-examine the problem, and the hints you've been given.
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello gayathri murugesan ;

just go through my code and find mistake..
this code is working........
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic