wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Boolean Method Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Boolean Method Problem" Watch "Boolean Method Problem" New topic
Author

Boolean Method Problem

Olivier Legat
Ranch Hand

Joined: Nov 17, 2007
Posts: 176

Hello everyone,

I got this method which is meant to check if a name exists or not in a Random Access File. Basically, before I add an extra, I need to run this method to make sure that that line doesn't already exist somewhere else in the file. But no matter what happens it ALWAYS returns false

Here's the code:


Any ideas why this is happening?


Olly
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11172
    
  16

if the file is not too big, try putting in some print statements to see what the strings are it's comparing at each step. I usually do something like

system.out.println("|" + myString + "|");

the pipes let me know EXACTLY where the string starts/ends in case there is whitespace on the beginning or end i may not see otherwise.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Olivier Legat
Ranch Hand

Joined: Nov 17, 2007
Posts: 176

Wow! That's really helped Fred Rosenberger. I found the problem. Thanks loads


 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Boolean Method Problem
 
Similar Threads
How to Copy All files with certain extensions from a directory and all its subs
IO
problem in checking the dimensions of an image.
equals & hashcode doubt
To fetch files from a dir