Characters like "@" in the user info portion of a URI have to be escaped. When parsing such a URI, the URI consumer should unescape any escaped characters:
import java.net.URI;
import java.net.URISyntaxException;
public class URITest {
public static void main(String[] args) throws URISyntaxException {
URI uri = new URI("http", "user:p@ss", "example.com", -1,
null, null, null);
System.out.println(uri.toString());
URI uri2 = new URI(uri.toString());
System.out.println(uri2.getUserInfo());
}
}
On my system, this outputs:
http://user:p%40ss@example.com
user:p@ss
In the original question, it looks like you're not escaping the '@' when constructing the URI. In your comment to @leblma, it sounds like whatever is using the URI isn't unescaping the % sequence.