Local file protocol for java.net.URL

Ziddia picture Ziddia · Dec 6, 2011 · Viewed 38.3k times · Source

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.

Answer

Kohányi Róbert picture Kohányi Róbert · Dec 6, 2011

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.