At the moment I can retrieve a text page as follows
HttpClient client = new DefaultHttpClient();
HttpGet get = new HttpGet(
"http://google.com");
try {
HttpResponse response = client.execute(get);
BufferedReader rd = new BufferedReader(new InputStreamReader(
response.getEntity().getContent()));
String line = "";
while ((line = rd.readLine()) != null) {
System.out.println(line);
}
} catch (IOException e) {
e.printStackTrace();
}
Suppose get is targeted at a binary file. How would I save this correctly to disk?
Just don’t go via a
Reader– read the data from theInputStreamand write to anOutputStream.