I am not able to write a pdf file downloaded from a url into android storage.
I have read all related questions on this site, but still unable to fighre out whats wrong with my code.

Error is in 
pdfFile.createNewFile(); inside try{ } block.

```
private class DownloadFile extends AsyncTask<String, Void, Void> {

        @Override
        protected Void doInBackground(String... strings) {
            String fileUrl = strings[0];  
            String fileName = strings[1];  
            String extStorageDirectory = Environment.getExternalStorageDirectory().toString();
            File folder = new File(extStorageDirectory, "/test/");
            folder.mkdirs();

            File pdfFile = new File(folder, fileName);

            try{
                pdfFile.getParentFile().mkdirs();
                pdfFile.createNewFile();
            }catch (IOException e){
                e.printStackTrace();
            }
            FileDownloader.downloadFile(fileUrl, pdfFile);
            return null;
        }

```

My Logcat

```
06-24 19:11:26.886 22920-22999/in.ac.iitd.bsw.iitdapp W/System.err: java.io.IOException: open failed: ENOENT (No such file or directory)
06-24 19:11:26.886 22920-22999/in.ac.iitd.bsw.iitdapp W/System.err:     at java.io.File.createNewFile(File.java:939)
06-24 19:11:26.886 22920-22999/in.ac.iitd.bsw.iitdapp W/System.err:     at in.ac.iitd.bsw.iitdapp.VolleyDownload$DownloadFile.doInBackground(VolleyDownload.java:112)
06-24 19:11:26.888 22920-22999/in.ac.iitd.bsw.iitdapp W/System.err:     at in.ac.iitd.bsw.iitdapp.VolleyDownload$DownloadFile.doInBackground(VolleyDownload.java:96)
06-24 19:11:26.888 22920-22999/in.ac.iitd.bsw.iitdapp W/System.err:     at android.os.AsyncTask$2.call(AsyncTask.java:295)
06-24 19:11:26.888 22920-22999/in.ac.iitd.bsw.iitdapp W/System.err:     at java.util.concurrent.FutureTask.run(FutureTask.java:237)
06-24 19:11:26.889 22920-22999/in.ac.iitd.bsw.iitdapp W/System.err:     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
06-24 19:11:26.889 22920-22999/in.ac.iitd.bsw.iitdapp W/System.err:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
06-24 19:11:26.889 22920-22999/in.ac.iitd.bsw.iitdapp W/System.err:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
06-24 19:11:26.889 22920-22999/in.ac.iitd.bsw.iitdapp W/System.err:     at java.lang.Thread.run(Thread.java:818)
06-24 19:11:26.889 22920-22999/in.ac.iitd.bsw.iitdapp W/System.err: Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory)
06-24 19:11:26.889 22920-22999/in.ac.iitd.bsw.iitdapp W/System.err:     at libcore.io.Posix.open(Native Method)
06-24 19:11:26.890 22920-22999/in.ac.iitd.bsw.iitdapp W/System.err:     at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186)
06-24 19:11:26.890 22920-22999/in.ac.iitd.bsw.iitdapp W/System.err:     at java.io.File.createNewFile(File.java:932)
06-24 19:11:26.890 22920-22999/in.ac.iitd.bsw.iitdapp W/System.err:     ... 8 more
06-24 19:11:26.890 22920-22999/in.ac.iitd.bsw.iitdapp W/System: ClassLoader referenced unknown path: /system/framework/tcmclient.jar
06-24 19:11:27.040 22920-22999/in.ac.iitd.bsw.iitdapp W/System.err: java.io.FileNotFoundException: /storage/emulated/0/test/maven.pdf: open failed: ENOENT (No such file or directory)
06-24 19:11:27.041 22920-22999/in.ac.iitd.bsw.iitdapp W/System.err:     at libcore.io.IoBridge.open(IoBridge.java:452)
06-24 19:11:27.041 22920-22999/in.ac.iitd.bsw.iitdapp W/System.err:     at java.io.FileOutputStream.<init>(FileOutputStream.java:87)
06-24 19:11:27.041 22920-22999/in.ac.iitd.bsw.iitdapp W/System.err:     at java.io.FileOutputStream.<init>(FileOutputStream.java:72)
06-24 19:11:27.041 22920-22999/in.ac.iitd.bsw.iitdapp W/System.err:     at in.ac.iitd.bsw.iitdapp.FileDownloader.downloadFile(FileDownloader.java:27)
06-24 19:11:27.041 22920-22999/in.ac.iitd.bsw.iitdapp W/System.err:     at in.ac.iitd.bsw.iitdapp.VolleyDownload$DownloadFile.doInBackground(VolleyDownload.java:116)
06-24 19:11:27.041 22920-22999/in.ac.iitd.bsw.iitdapp W/System.err:     at in.ac.iitd.bsw.iitdapp.VolleyDownload$DownloadFile.doInBackground(VolleyDownload.java:96)
06-24 19:11:27.041 22920-22999/in.ac.iitd.bsw.iitdapp W/System.err:     at android.os.AsyncTask$2.call(AsyncTask.java:295)
06-24 19:11:27.041 22920-22999/in.ac.iitd.bsw.iitdapp W/System.err:     at java.util.concurrent.FutureTask.run(FutureTask.java:237)
06-24 19:11:27.041 22920-22999/in.ac.iitd.bsw.iitdapp W/System.err:     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
06-24 19:11:27.041 22920-22999/in.ac.iitd.bsw.iitdapp W/System.err:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
06-24 19:11:27.041 22920-22999/in.ac.iitd.bsw.iitdapp W/System.err:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
06-24 19:11:27.042 22920-22999/in.ac.iitd.bsw.iitdapp W/System.err:     at java.lang.Thread.run(Thread.java:818)
06-24 19:11:27.042 22920-22999/in.ac.iitd.bsw.iitdapp W/System.err: Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory)
06-24 19:11:27.043 22920-22999/in.ac.iitd.bsw.iitdapp W/System.err:     at libcore.io.Posix.open(Native Method)
06-24 19:11:27.043 22920-22999/in.ac.iitd.bsw.iitdapp W/System.err:     at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186)
06-24 19:11:27.043 22920-22999/in.ac.iitd.bsw.iitdapp W/System.err:     at libcore.io.IoBridge.open(IoBridge.java:438)
06-24 19:11:27.043 22920-22999/in.ac.iitd.bsw.iitdapp W/System.err:     ... 11 more

```

I have correctly set permission in Android Manifest