문제

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

도움이 되었습니까?

해결책 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

다른 팁

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
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top