代码都是些基础代码,不过那个本地File的URI的创建搞了我很长时间,在网上也没搜到啥··
先后试过:
new URI("file://C://g.txt")
Exception:Illegal character in authority
new URI("file://C:/g.txt")
Exception:URI has an authority component
最后试出了结果
new URI("file:/c:/g3.txt")
最后从有关书籍上查得,正解应该是这样的.
URL url = new URL("file://" + realPath); //for Linux
URL url = new URL("file:///" + realPath); //for Windows