Local file protocol for java.net.URL

☆樱花仙子☆ 提交于 2020-01-09 07:55:33

问题


What's the protocol for local files using URL? I've downloaded a file using Java and I need to know how to access it, not using File, but using URL.


回答1:


Unix

file://localhost/<path>
file:///<path>

Windows

file://localhost/<drive>|/<path>
file:///<drive>|/<path>
file://localhost/<drive>:/<path>
file:///<drive>:/<path>

For more information see the related Wikipedia article.




回答2:


You may use file:/// and file path. For e.g. file:///c:/temp.txt



来源:https://stackoverflow.com/questions/8406025/local-file-protocol-for-java-net-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!