如何转义 java 中的“@”字符

How to escape '@' character in java

我正在编写一个方法来建立与 FTP 的连接,并且在配置 URL 时,我的密码包含“@”字符,这与主机名冲突。如何解决?这个字符可以转义吗?

URL: ftp://xyz:abc@27@www.sezin.com/home/pk09

强烈劝你不要这样做。引用 (以防它被清理):

Auth information in the URL was deprecated years ago and implementors in various realms (browsers, for instance) are actively removing it, as it's ridiculously insecure. Surely there's a way to connect to your FTP server and then supply the auth info (which is still ridiculously insecure -- this is FTP -- but may at least be supported).

但是 user information in the authority section of a URL(已弃用)是百分比编码的,因此:

ftp://xyz:abc%4027@www.sezin.com/home/pk09

%40@ 的百分比编码值。