URLConnection.getContentLength() returns -1
<p>I have a URL which, when I enter in browser, opens the image perfectly. But when I try the following code, I get getContentLength() as -1:</p>

<pre><code>URL url = new URL(imageUrl);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();

// determine the image size and allocate a buffer
int fileSize = connection.getContentLength();
</code></pre>

<p>Please guide me what can be the reason behind this?</p>
