• Post Reply Bookmark Topic Watch Topic
  • New Topic

io question

 
patrick tang
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all, i've a question about io

i'm trying to use method findStore(string s) to find the store with the same name as s. the idea is in gui,i can select the store from a combobox and read the catalogue of that particular store to a textarea. the problem is that findStore doesnt work. you may see that there're two stores in the mall. when i try to find store2, it wont return yes and that store file. i've spent a lot of time on it but still dont get it.
can anyone pls help me out...again? thanks in advance
[ February 18, 2002: Message edited by: patrick tang ]
 
John Spindler
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are these stored in two different files?
Mall.java and StoreTest.java?
[ February 27, 2002: Message edited by: John Spindler ]
 
Kathy Rogers
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Patrick,
Looking at the Java API, getName() returns the very last element of the file's path - so for a file C:\mall\store2, it would return "store2". That's what s2 is set to. But you're setting s1 to "mall\store2" ("mall" + File.separator + s) - so s1 and s2 won't be equal and you won't find the store. I think you should probably just compare s2 to s.
Hope this helps,
Kathy
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!