String thisurl ="http://songolum.com/file/ppdVkTxqhwcJu-CAzCgtNeICMi8mHZnKQBgnksb5o2Q/Ed%2BSheeran%2B-%2BPerfect.mp3?r=idz&dl=311&ref=ed-sheran-perfect"; URL url = null; try { url = new URL(thisurl); HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection(); try { // urlConnection.setRequestProperty("Transfer-Encoding", "chunked"); urlConnection.setRequestProperty("Accept-Encoding", "identity"); urlConnection.setDoOutput(true); urlConnection.setChunkedStreamingMode(0); int l=0; InputStream in = new BufferedInputStream(urlConnection.getInputStream()); while(in.read()!=-1) { l=l+in.read(); } System.out.println("Content-length" +l);