File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Boolean Method Problem" Watch "Boolean Method Problem" New topic

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?

fred rosenberger
lowercase baba

Joined: Oct 02, 2003
Posts: 11955

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:
subject: Boolean Method Problem
It's not a secret anymore!