Created
June 2, 2012 13:35
-
-
Save hanigamal/2858458 to your computer and use it in GitHub Desktop.
Remote PDF
This file contains hidden or 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
try { | |
URL u = new URL("http://hanigamal.net/resume.pdf"); | |
HttpURLConnection c = (HttpURLConnection) u.openConnection(); | |
c.setRequestMethod("GET"); | |
c.setDoOutput(true); | |
c.connect(); | |
String fileName = Environment.getExternalStorageDirectory().getAbsolutePath(); | |
FileOutputStream f = new FileOutputStream(new File(fileName,"my.pdf")); | |
InputStream in = c.getInputStream(); | |
byte[] buffer = new byte[1024]; | |
int len1 = 0; | |
while ( (len1 = in.read(buffer)) > 0 ) { | |
f.write(buffer,0, len1); | |
} | |
f.close(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment