java.net.URISyntaxException [英] java.net.URISyntaxException
问题描述
我得到了这个例外。但这个例外不再重现。我想得到这个原因
I have get this exception. but this exception is not reproduced again. I want to get the cause of this
Exception Caught while Checking tag in XMLjava.net.URISyntaxException:
Illegal character in opaque part at index 2:
C:\Documents and Settings\All Users\.SF\config\sd.xml
stacktrace net.sf.saxon.trans.XPathException.
为什么发生此异常。如何处理,以便它不会重现。
Why this exception occured. How to deal with so it will not reproduce.
推荐答案
基本上C:\Documents and Settings \所有用户\.SF\config\sd.xml
是路径名,而不是有效的URI。如果要将路径名转换为file:URI,请执行以下操作:
Basically "C:\Documents and Settings\All Users\.SF\config\sd.xml"
is a pathname, and not a valid URI. If you want to turn a pathname into a "file:" URI, then do the following:
File f = new File("C:\Documents and Settings\All Users\.SF\config\sd.xml");
URI u = f.toURI();
这是在Java中将路径名转换为有效URI的最简单,最可靠和最便携的方法。
This is the simplest, and most reliable and portable way to turn a pathname into a valid URI in Java.
但你需要意识到file:URI有许多警告,如 File.toURI()
方法。例如,在一台机器上创建的file:URI通常表示另一台机器上的不同资源(或根本没有资源)。
But you need to realize that "file:" URIs have a number of caveats, as described in the javadocs for the File.toURI()
method. For example, a "file:" URI created on one machine usually denotes a different resource (or no resource at all) on another machine.
这篇关于java.net.URISyntaxException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!