URISyntaxException

java.net.URISyntaxException: Illegal character in opaque part at index 2: C:\xxx\xxx

因为这个是URI和普通的path 有区别,看下源码,意思是要基于某种协议

一般是file 或者http,学习大数据的时候有 hdfs:///   spark:/// 协议

new URI("file:///E:/code/input/join/pd.txt")
/**
 * Constructs a URI by parsing the given string.
 *
 * <p> This constructor parses the given string exactly as specified by the
 * grammar in <a
 * href="http://www.ietf.org/rfc/rfc2396.txt">RFC&nbsp;2396</a>,
 * Appendix&nbsp;A, <b><i>except for the following deviations:</i></b> </p>
 *
 * <ul>
 *
 *   <li><p> An empty authority component is permitted as long as it is
 *   followed by a non-empty path, a query component, or a fragment
 *   component.  This allows the parsing of URIs such as
 *   {@code "file:///foo/bar"}, which seems to be the intent of
 *   RFC&nbsp;2396 although the grammar does not permit it.  If the
 *   authority component is empty then the user-information, host, and port
 *   components are undefined. </p></li>
 *
 *   <li><p> Empty relative paths are permitted; this seems to be the
 *   intent of RFC&nbsp;2396 although the grammar does not permit it.  The
 *   primary consequence of this deviation is that a standalone fragment
 *   such as {@code "#foo"} parses as a relative URI with an empty path
 *   and the given fragment, and can be usefully <a
 *   href="#resolve-frag">resolved</a> against a base URI.
 *
 *   <li><p> IPv4 addresses in host components are parsed rigorously, as
 *   specified by <a
 *   href="http://www.ietf.org/rfc/rfc2732.txt">RFC&nbsp;2732</a>: Each
 *   element of a dotted-quad address must contain no more than three
 *   decimal digits.  Each element is further constrained to have a value
 *   no greater than 255. </p></li>
 *
 *   <li> <p> Hostnames in host components that comprise only a single
 *   domain label are permitted to start with an <i>alphanum</i>
 *   character. This seems to be the intent of <a
 *   href="http://www.ietf.org/rfc/rfc2396.txt">RFC&nbsp;2396</a>
 *   section&nbsp;3.2.2 although the grammar does not permit it. The
 *   consequence of this deviation is that the authority component of a
 *   hierarchical URI such as {@code s://123}, will parse as a server-based
 *   authority. </p></li>
 *
 *   <li><p> IPv6 addresses are permitted for the host component.  An IPv6
 *   address must be enclosed in square brackets ({@code '['} and
 *   {@code ']'}) as specified by <a
 *   href="http://www.ietf.org/rfc/rfc2732.txt">RFC&nbsp;2732</a>.  The
 *   IPv6 address itself must parse according to <a
 *   href="http://www.ietf.org/rfc/rfc2373.txt">RFC&nbsp;2373</a>.  IPv6
 *   addresses are further constrained to describe no more than sixteen
 *   bytes of address information, a constraint implicit in RFC&nbsp;2373
 *   but not expressible in the grammar. </p></li>
 *
 *   <li><p> Characters in the <i>other</i> category are permitted wherever
 *   RFC&nbsp;2396 permits <i>escaped</i> octets, that is, in the
 *   user-information, path, query, and fragment components, as well as in
 *   the authority component if the authority is registry-based.  This
 *   allows URIs to contain Unicode characters beyond those in the US-ASCII
 *   character set. </p></li>
 *
 * </ul>
 *
 * @param  str   The string to be parsed into a URI
 *
 * @throws  NullPointerException
 *          If {@code str} is {@code null}
 *
 * @throws  URISyntaxException
 *          If the given string violates RFC&nbsp;2396, as augmented
 *          by the above deviations
 */
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值