Name: bsC130419 Date: 07/27/2001
java version "1.4.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b65)
Java HotSpot(TM) Client VM (build 1.4.0-beta-b65, mixed mode)
An URLConnection supports output with the method getOutputStream. The API
documentation
says:
Throws:
IOException - if an I/O error occurs while creating the output stream.
UnknownServiceException - if the protocol does not support output
Unfortunately even an URLConnection to a file (of course with the file
protocol) does not
support output. This is a pity and because of this there is no generic way to
send output
to an URL (a file in an URL is not writable).
Also it makes no sense not to support output in this protocol. Of course if you
expect any
protocol to support output, it would be the file protocol.
URL url = new File("test.txt").toURL();
URLConnection connection = url.openConnection();
connection.setDoOutput(true);
OutputStream output = connection.getOutputStream(); //throws an
UnknownServiceException
This bug is related to bug 1243005. The evalutation of that bug indeed mentions
that the file protocol does not support writing in the Java libraries. But if I
would expect any protocol to support output, it would be the file protocol.
(Review ID: 128950)
======================================================================