| Author |
Parsing a String
|
anees ahamed
Ranch Hand
Joined: Feb 19, 2008
Posts: 31
|
|
Hi all, Let me first say that I have posted this in sun forums and it didnt work out for me. I am reframing my question here for your valuable suggestions and comments. This is the general format in which I get data from database(This is an example where the group names and user names are variables and the other syntax will be exactly the same). Literally I do not know what kind of string is this and what to do with this. I need an output of the format For users with no groups, it should be I would like to have these outputs in some array or as any collection in Java. How can I accomplish this? Anees
|
 |
Nitesh Kant
Bartender
Joined: Feb 25, 2007
Posts: 1638
|
|
For a not so difficult string parsing algorithm, Scanner proves useful. Try it out and let us know whether you got what you desired
|
apigee, a better way to API!
|
 |
arulk pillai
Author
Ranch Hand
Joined: May 31, 2007
Posts: 3190
|
|
Write a simple parser to convert it to the format you want it in. Regex can be useful
|
Java Interview Questions and Answers Blog | Amazon.com profile | Java Interview Books
|
 |
Maneesh Godbole
Saloon Keeper
Joined: Jul 26, 2007
Posts: 8566
|
|
Originally posted by anees ahamed: Let me first say that I have posted this in sun forums and it didnt work out for me.
Thank you for declaring this right at the onset. We really appreciate it.
|
[Donate a pint, save a life!] [How to ask questions] [Onff-turn it on!]
|
 |
Jesper de Jong
Java Cowboy
Bartender
Joined: Aug 16, 2005
Posts: 12953
|
|
Originally posted by anees ahamed: Literally I do not know what kind of string is this and what to do with this.
It looks like JSON. There are a number of Java libraries available to parse JSON, they are listed on the website.
|
Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
|
 |
Darryl Burke
Bartender
Joined: May 03, 2008
Posts: 4203
|
|
Originally posted by Maneesh Godbole: Thank you for declaring this right at the onset. We really appreciate it.
What's not so nice is continuing the topic on the other forum even after posting here, not mentioning the cross post on the other forum, and not providing a link. http://forums.sun.com/thread.jspa?threadID=5342229
|
luck, db
There are no new questions, but there may be new answers.
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32830
|
|
|
I think DB is correct; everybody posting ought to know about other discussions. Read this FAQ.
|
 |
anees ahamed
Ranch Hand
Joined: Feb 19, 2008
Posts: 31
|
|
I got it solved, For anyone having future use, this is how I solved. which gave me the output
|
 |
 |
|
|
subject: Parsing a String
|
|
|