• Post Reply Bookmark Topic Watch Topic
  • New Topic

comma separate values  RSS feed

 
Tilak Gorantala
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Team,

I need to get the title from a server which has 3 title names separated by commas(i.e., for example - VP, GS, eService ). How to get the title value properly and also there should not be any commas in title after retrieving the data.

Expected output : VP GS eService

Thanks,
Gopi.
 
Tim Cooke
Marshal
Posts: 4048
239
Clojure IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What specific problem are you facing? What have you tried so far?
 
Tilak Gorantala
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
title of some user is separated with commas and our application is not taking that title as it has commas in it and our application which has SSO(single sogn on) code, is taking his old title. I just want to remove the commas and display the title correct in my application.

I am writing s String.split functionality for this to remove the commas.

if((profileFieldValue = in.readLine()) != null) {
String[] ar=str.split(",");
}


profileFieldValue gets the title value from LDAP server. if it is unable to pick the new title then it displays the old title based on our SSO code.
 
Tilak Gorantala
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gopi Gorantala wrote:title of some user is separated with commas and our application is not taking that title as it has commas in it and our application which has SSO(single sogn on) code, is taking his old title. I just want to remove the commas and display the title correct in my application.

I am writing s String.split functionality for this to remove the commas.

if((profileFieldValue = in.readLine()) != null) {
String[] ar=str.split(",");
}


profileFieldValue gets the title value from LDAP server. if it is unable to pick the new title then it displays the old title based on our SSO code.


or can I use this ??

profileFieldValue = (ProfileFieldValue)userProfileMap.get(Long.valueOf(profileField.getID())).split(",");
 
Tim Cooke
Marshal
Posts: 4048
239
Clojure IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK. You're throwing in a few other things into the mix here which is just confusing matters. Let's just talk about the comma separated string.

The String.split() method is the right solution for this

Now you can access each element individually to do with whatever you wish.
 
Tilak Gorantala
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Cooke wrote:OK. You're throwing in a few other things into the mix here which is just confusing matters. Let's just talk about the comma separated string.

The String.split() method is the right solution for this

Now you can access each element individually to do with whatever you wish.


Thanks, But I want an output as "VP GS eService". commas should get deleted.
 
Tim Cooke
Marshal
Posts: 4048
239
Clojure IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So you could now loop through your array of Strings and build a new string from each item in the desired format.

Or perhaps instead of using String.split() maybe there's some other method in the String class you could use to strip out the commas? What do you think?
 
Tilak Gorantala
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Cooke wrote:So you could now loop through your array of Strings and build a new string from each item in the desired format.

Or perhaps instead of using String.split() maybe there's some other method in the String class you could use to strip out the commas? What do you think?



Tim,

I used String.split() functionality and, I've put them all in to an array of Strings and build in a new string.. that worked clearly.

Thanks.. :-)

 
Tim Cooke
Marshal
Posts: 4048
239
Clojure IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Glad you got it working. To simplify things a little what do you think about using the String.replace() method to get rid of the commas?

Much neater wouldn't you say?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!