Created
April 8, 2020 16:42
-
-
Save apexdodge/db1d691d3c1951c114bc75fe0db0aae4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.http.HttpEntity; | |
import org.apache.http.HttpResponse; | |
import org.apache.http.client.HttpClient; | |
import org.apache.http.client.methods.HttpGet; | |
import org.apache.http.impl.client.HttpClients; | |
public void downloadFileUtil(String pdfUrlToDownload) { | |
HttpClient httpClient = HttpClients.createDefault(); | |
HttpGet httpGet = new HttpGet(pdfUrlToDownload); | |
HttpResponse response; | |
response = httpClient.execute(httpGet); | |
HttpEntity entity = response.getEntity(); | |
FileOutputStream outstream = new FileOutputStream("/storage/directory/filename.pdf"); | |
entity.writeTo(outstream); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment