Java getOutputStream() surprises

Uncategorized Add comments

As a not to my future self, apparently you need to open the connection before setting doOutput:

URLConnection connection = url.openConnection();
connection.setDoOutput(true);

return connection.getOutputStream();

It’s a good thing that’s poorly documented and non-obvious, and that it fails in misleading ways.

Leave a Reply

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in