This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
...depending on what he has in mind. If he's trying to generate URL's, then a URLEncoder probably really is the right thing to use. But then again, URLEncoder doesn't solve the problem explicitly stated in the original post.
However, it may just be that he wanted to change spaces to %20 for other reasons, saw the URLEncoder, tried it, and found that it was a bad fit for his application after all.
I was just assuming he knows what he wants to do even if he doesn't know how to do it and I don't know why he wants to. I also assume that if he tried URLEncoder and it changed spaces to +s, he would verify that +s are wrong for his purposes before posting the question.