import java.net.*;
public class TestURI {
public static void main(String args[]) throws URISyntaxException
{
String first = new String("foo");
String second = new String("bar");
String third = new String("[space or another space]");
URI temp = new URI(first, second, third);
System.out.println(temp.getFragment());
}
}
Когда я запускаю приведенный выше код в JDK 1.4, я получаю
[пробел или другой пробел]
Когда я запускаю тот же код в JDK 1.5 / 1.6, я получаюследующее:
[пробел% 20or% 20another% 20space]
Может кто-нибудь сказать мне, что изменилось?
Спасибо, Радж
Редактировать:
Если я сделаю что-то вроде следующего, это сработает:
import java.net.*;
public class TestURI {
public static void main(String args[]) throws URISyntaxException
{
String first = new String("foo");
String second = new String("bar");
String third = new String("[space or another space]").replaceAll("\\[", "leftSB").replaceAll("\\]", "rightSB");
URI temp = new URI(first, second, third);
System.out.println(temp.getFragment().replaceAll("leftSB", "\\[").replaceAll("rightSB", "\\]"));
}
}