File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Reading values from a String Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Reading values from a String" Watch "Reading values from a String" New topic

Reading values from a String

siva sankar
Ranch Hand

Joined: Jul 13, 2006
Posts: 68
I am hitting a webservice which is returning a String as shown below.

String output="

In the above output,each line contains a attribute name and the next corresponding line have the value for this attribute.
For example,the line1 and line2 in above output is and identitydetails.attribute.value=John.
Now I want to add uid(from line1) as a key and John(from line2) as value to a HashMap. The same has to be done for other lines in the output and add key/value pairs to HashMap.

Can anyone suggest me the best approach to achieve the above requirement.

Thanks in Advance,
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13037
That is the name=value format used by "properties" so you could create a java.util.Properties object to hold and read values.

Create a StringReader from the String, create an empty Properties and then load it from the Reader.

I agree. Here's the link:
subject: Reading values from a String
jQuery in Action, 3rd edition