public Response download ( String url , File destination , String ... headers ) throws IOException { try ( Response resp = response ( url , headers ) ) { if ( resp . isSuccessful ( ) ) { try ( BufferedSink sink = Okio . buffer ( Okio . sink ( destination ) ) ) { resp . body ( ) . source ( ) . readAll ( sink ) ; } } return resp ; } }
Download the resource at the URL with the headers and write it to the file .