Question

I wrote a SVNkit implementation which checks out svn repositories. As long as the url of the repository doesn't contain white spaces there is no problem.

But if the url does contain white space an error occurs. something with url not found.

I tried already a couple of things:

parseURIDecoded()
parseURIEncoded()

and also Ive tried to replace the white spaces with %20

-bgvv1983

Était-ce utile?

La solution 3

I found out that i made a stupid mistake. in the original shellscript there was the line

svn checkout https://gforge.cs.vu.nl/svn/ibis/mpj/trunk ibis-mpj

so I copied the url + the folder name. because I was fixed on the white space problem,I didnt see my mistake.

So for now I dont have the problem anymore

bgv1983

Autres conseils

I normally use this call for passing url : SvnTarget.fromURL(SVNURL.parseURIEncoded("URL String));

This should take care of white spaces.

If you're initializing URIs from Strings, you probably want to use URLEncoder.encode.

Here's a simple snippet:

String myUrlString = "http://www.google.com?q=foo bar";
try {
    URI uri = new URI(myUrlString);
}
// will trigger and show stack trace
catch (URISyntaxException u) {
    u.printStackTrace();
}
try {
    URI uri = new URI(URLEncoder.encode(myUrlString, "UTF-8"));
    System.out.println("OK");
}
// no catch statement will trigger
catch (URISyntaxException u) {
    u.printStackTrace();
}
catch (UnsupportedEncodingException ue) {
    ue.printStackTrace();
}

Output:

[the stack trace from the 1st "try" statement]
OK
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top