what are the protocols that commons-io FileUtils.copyUrlToFile allow to copy from?
1 Answers
Short answer: It depends on the JVM, but at least http
, https
, file
, and jar
will work.
Long answer: FileUils uses Java's java.net.URL
to handle the actual connection. java.net.url
uses protocol-specific instances of URLStreamHandler to implement different protocol. The handlers are found dynamically, and you can add your own. According to the Javadoc, you are guaranteed to have http, https, file and jar handlers:
Protocol handlers for the following protocols are guaranteed to exist on the search path :-
http, https, file, and jar
Handlers for other protocols are not guaranteed to exist on every JVM. On my Windows x64 machine, which uses Java 8u111, under sun.net.www.protocol
I also see mailto
, ftp
and netdoc
handlers, which means that these protocols are supported. Note that the fact that a protocol is supported, doesn't mean that copyUrlToFile
makes sense for it (e.g. mailto)

- 28,965
- 9
- 65
- 105