File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes I/O and Streams and the fly likes error in retrieving from file. Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » I/O and Streams
Reply Bookmark "error in retrieving from file." Watch "error in retrieving from file." New topic
Author

error in retrieving from file.

gayathri murugesan
Ranch Hand

Joined: Dec 21, 2009
Posts: 31


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.


Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 32421
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".


Android appsImageJ pluginsJava web charts
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12612
Look at the Javadocs for BufferedReader's read() method: what do you expect to happen?
gayathri murugesan
Ranch Hand

Joined: Dec 21, 2009
Posts: 31
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
Rancher

Joined: Sep 29, 2008
Posts: 12612
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?

This message was edited 1 time. Last update was at by David Newton

gayathri murugesan
Ranch Hand

Joined: Dec 21, 2009
Posts: 31
with length method also i m getting the same type of problem.

David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12612


I think you should take a step back and re-examine the problem, and the hints you've been given.

This message was edited 2 times. Last update was at by David Newton

pramod reddy
Greenhorn

Joined: Jan 10, 2008
Posts: 15
Hello gayathri murugesan ;

just go through my code and find mistake..
this code is working........

This message was edited 2 times. Last update was at by pramod reddy

 
 
subject: error in retrieving from file.
 
developer file tools