Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Illegal character in path at index 16 [duplicate]

Tags:

java

I am getting the following error in RAD:

java.net.URISyntaxException: Illegal character in path at index 16: file:/E:/Program Files/IBM/SDP/runtimes/base...... 

Could you please let me know what is the error and how to resolve it?

like image 316
Srinivasan Avatar asked Feb 14 '11 12:02

Srinivasan


People also ask

What are the illegal characters in path?

The "Illegal characters" exception means that the file path string you are passing to ReadXml is wrong: it is not a valid path. It may contain '?' , or ':' in the wrong place, or '*' for example. You need to look at the value, check what it is, and work out where the illegal character(s) are coming from.

What is an illegal character in Java?

The illegal character compilation error is a file type encoding error. It's produced if we use an incorrect encoding in our files when they are created. As result, in languages like Java, we can get this type of error when we try to compile our project.

What is Java net URISyntaxException?

public class URISyntaxException extends Exception. Checked exception thrown to indicate that a string could not be parsed as a URI reference.


2 Answers

There's an illegal character at index 16. I'd say it doesn't like the space in the path. You can percent encode special characters like spaces. Replace it with a %20 in this case.

The question I linked to above suggests using URLEncoder:

String thePath = "file://E:/Program Files/IBM/SDP/runtimes/base"; thePath = URLEncoder.encode(thePath, "UTF-8");  
like image 192
Jonathon Faust Avatar answered Oct 09 '22 18:10

Jonathon Faust


I ran into the same thing with the Bing Map API. URLEncoder just made things worse, but a replaceAll(" ","%20"); did the trick.

like image 30
John Avatar answered Oct 09 '22 18:10

John