In Java, how can I avoid an HTTP 404 getting a file:// URL with special characters in it?

It's not a bug, it's the fact that it's not a valid URL.

It's not a bug, it's the fact that it's not a valid URL. You obviously need to escape those blanks into %20, for starters. I don't know what you do with the apostrophe.

This blog suggests that it should become a %27. Try it and see. Or just try java.net.

URLEncoder to see what it gives you.

I don't believe you can use URLEncoder, as it will encode everything including the "://" characters. Java itself does not have a class to do the necessary encoding. – Eddie Jun 5 '09 at 23:58 You might be right, Eddie.

I didn't try it myself. I was just rooting around for something in the API that might help. Perhaps that wasn't a good idea.

– duffymo Jun 6 '09 at 0:06.

Why not construct a URI first and then call the toURL() method. More info here. UPDATE Or even better, why not use the URI directly in the constructor of the File, since the URI class takes care of the encoding for you.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions