Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

'%' an accepted character in URL constructor

Status
Not open for further replies.

25884

Programmer
Mar 12, 2001
46
AP
For the below piece of code I get an IllegalArgumentException

import java.io.*;
import java.net.*;

public class Test1
{
public static void main(String args[])
{
try {
URL url = new URL("file:D:/test/aa%bb/c");
InputStream is = url.openStream();
} catch (Exception e)
{
e.printStackTrace();
}

}
}

I '%' an accepted character in URL constructor, If its not, is there any documentation stating its not allowed?

Thanks !
 
% is legal, but only when used to escape other illegal characters. In other words it must be followed by a numeric, like this one from the W3C standards:
Code:
gopher://spinaltap.micro.umn.edu/00/Weather/California/Los[red]%20[/red]Angeles
Here is is used to 'allow' a space character.

Steve

[small]"Every program can be reduced by one instruction, and every program has at least one bug. Therefore, any program can be reduced to one instruction which doesn't work." (Object::perlDesignPatterns)[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top