Skip to content

Instantly share code, notes, and snippets.

@jfarcand
Created September 8, 2010 21:59
Show Gist options
  • Save jfarcand/570918 to your computer and use it in GitHub Desktop.
Save jfarcand/570918 to your computer and use it in GitHub Desktop.
Response response = httpClient.prepareGet(path)
.setRealm(createRealm())
.setProxyServer(createProxyServer())
.execute(completionHandler).get();
// TODO: Use the underlying ByteBuffer directly instead. Totally inneficient to loads the
// bytes in memory.
FileOutputStream fs = new FileOutputStream(tmp);
try {
final byte[] buffer = new byte[4 * 1024];
int n = 0;
while (-1 != (n = response.getResponseBodyAsStream().read(buffer))) {
fs.write(buffer, 0, n);
}
} finally {
fs.close();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment