What's the simplest java way to download a file over HTTPS, preserving timestamps and using the content-disposition for the filename? Is there any java library at a higher level than apache-httpclient?
Currently I've got:
HttpClient httpClient = new DefaultHttpClient();
HttpResponse httpResponse = httpClient.execute(new HttpGet(parser.sourceUrl));
Header cd = httpResponse.getLastHeader("Content-Disposition");
String filename = cd.getValue().split(";")[1].split("=")[1]; // TODO(jayen): unhack
HttpEntity httpEntity = httpResponse.getEntity();
System.out.println("Saving " + filename);
httpEntity.writeTo(new FileOutputStream(folder.getCanonicalPath() + File.separator + filename));
if (httpResponse.containsHeader("Last-Modified")) {
System.err.println("Please implement timestamping");
} else {
System.out.println("No timestamp available!");
}