Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Boolean Method Problem

 
Olivier Legat
Ranch Hand
Posts: 176
Chrome Mac Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Pie
Posts: 12097
30
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Olivier Legat
Ranch Hand
Posts: 176
Chrome Mac Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wow! That's really helped Fred Rosenberger. I found the problem. Thanks loads


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic