my dog learned polymorphism*
The moose likes Beginning Java and the fly likes How to search String for Map Key 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 "How to search String for Map Key" Watch "How to search String for Map Key" New topic

How to search String for Map Key

Raistlen Majere

Joined: Aug 03, 2009
Posts: 13
I have a list of file names stored as strings in a map along with their full path stored as values. I also have an xml file from a different location that I have read into a string. These xml files will contain different references to different files. Here is what I am trying to do:

1. Step through the map
2. Take the key, and search my xml string to see if that file name is referenced anywhere in the string.
3. If it is found, I will copy that file into the new location associated with the xml file.

My problem is, I can not seem to figure out how to take the key and search the xml string. I am using the indexOf because that is all I know of at this point. Thanks for any help.
Sebastian Janisch
Ranch Hand

Joined: Feb 23, 2009
Posts: 1183
What exactly is the problem you are facing. You already do search the xmlString for a match ...

JDBCSupport - An easy to use, light-weight JDBC framework -
Raistlen Majere

Joined: Aug 03, 2009
Posts: 13
Gentlemen, I am so sorry for wasting your time on this. I realized my call to the search was made before I actually filled the xml string

Once again, I am sorry for this and I will be more careful before I post again.
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 38064
We have all made mistakes like that!
I agree. Here's the link:
subject: How to search String for Map Key
Similar Threads
XMLUnit ignore Timestamps?
how to store multiple values in one key in hash table
Executing files....mp3 style
How do I covert on object into string
query regarding null key in hashmap