I have to download a file from a url which contains something like this:

`https://www.k4health.org/sites/default/files/প্রসব জনতি ফিস্টুলা চিহ্নিত করার চেকলিস্ট H11.pdf`

I tried encoding the filename before forming the URL but it's not working. The file is created in my SD card but with 0 bytes. This is how I tried it:

```
public String saveResourcesToSDCard(Resource res) {
    String filepath = null;
    String respath = "/bccp/" + bookID + "/resources/";
    StringBuilder sb = new StringBuilder();
    try {
        sb.append(Constant.RESOURCE_FTP);
        sb.append(new String(res.filename.getBytes(),"UTF-8"));
        URL url = new URL(sb.toString());
        //URL url = new URL(res.res_url);

        HttpURLConnection urlConnection = (HttpURLConnection) url
                .openConnection();
        urlConnection.setRequestMethod("GET");
        urlConnection.setDoOutput(true);
        urlConnection.connect();
        if(createDirIfNotExists(respath)){

            String filename = new String(res.filename.getBytes(),"UTF-8");
            Log.v("Local filename:", " " + filename);
            File file = new File(SDCardRoot, filename);
            if (file.createNewFile()) {
                file.createNewFile();
            }
            FileOutputStream fileOutput = new FileOutputStream(file);
            InputStream inputStream = urlConnection.getInputStream();

            int totalSize = urlConnection.getContentLength();
            int downloadedSize = 0;
            byte[] buffer = new byte[1024];
            int bufferLength = 0;
            while ((bufferLength = inputStream.read(buffer)) > 0) {
                fileOutput.write(buffer, 0, bufferLength);
                downloadedSize += bufferLength;
                Log.v("Progress:", "DownloadedSize: " + downloadedSize
                        + " TotalSize: " + totalSize);
            }
            fileOutput.close();
            if (downloadedSize == totalSize){
                filepath = file.getPath();
            }
        }
    } catch (MalformedURLException e) {
        e.printStackTrace();
        restartTask();
    } catch (IOException e) {
        filepath = null;
        restartTask();
        e.printStackTrace();
    }
    Log.v("filepath:", " " + filepath);
    return filepath;
}

```

this is the logcat:

```
03-16 16:38:25.478: W/System.err(21199): java.net.ProtocolException: Unexpected status line: <html>
03-16 16:38:25.480: W/System.err(21199):    at com.android.okhttp.internal.http.RawHeaders.setStatusLine(RawHeaders.java:108)
03-16 16:38:25.480: W/System.err(21199):    at com.android.okhttp.internal.http.RawHeaders.fromBytes(RawHeaders.java:308)
03-16 16:38:25.481: W/System.err(21199):    at com.android.okhttp.internal.http.HttpTransport.readResponseHeaders(HttpTransport.java:135)
03-16 16:38:25.482: W/System.err(21199):    at com.android.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:644)
03-16 16:38:25.483: W/System.err(21199):    at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:347)
03-16 16:38:25.483: W/System.err(21199):    at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:296)
03-16 16:38:25.484: W/System.err(21199):    at com.android.okhttp.internal.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:179)
03-16 16:38:25.484: W/System.err(21199):    at com.android.okhttp.internal.http.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:246)
03-16 16:38:25.486: W/System.err(21199):    at com.eatl.bdtoolkits.parsers.xmlparser.downloader.ResourceDownloader.saveResourcesToSDCard(ResourceDownloader.java:68)
03-16 16:38:25.486: W/System.err(21199):    at com.eatl.bdtoolkits.parsers.xmlparser.downloader.ResourceDownloader$DownloadResourceTask.doInBackground(ResourceDownloader.java:127)
03-16 16:38:25.487: W/System.err(21199):    at com.eatl.bdtoolkits.parsers.xmlparser.downloader.ResourceDownloader$DownloadResourceTask.doInBackground(ResourceDownloader.java:1)
03-16 16:38:25.487: W/System.err(21199):    at android.os.AsyncTask$2.call(AsyncTask.java:288)
03-16 16:38:25.488: W/System.err(21199):    at java.util.concurrent.FutureTask.run(FutureTask.java:237)
03-16 16:38:25.489: W/System.err(21199):    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
03-16 16:38:25.490: W/System.err(21199):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
03-16 16:38:25.491: W/System.err(21199):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
03-16 16:38:25.491: W/System.err(21199):    at java.lang.Thread.run(Thread.java:841)

```

What am I missing?