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 2396</a>,
* Appendix 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 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 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 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 2396</a>
* section 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 2732</a>. The
* IPv6 address itself must parse according to <a
* href="http://www.ietf.org/rfc/rfc2373.txt">RFC 2373</a>. IPv6
* addresses are further constrained to describe no more than sixteen
* bytes of address information, a constraint implicit in RFC 2373
* but not expressible in the grammar. </p></li>
*
* <li><p> Characters in the <i>other</i> category are permitted wherever
* RFC 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 2396, as augmented
* by the above deviations
*/