// verarebitet den Http Response und setzt den Inhalt
@Override
public void processResponse(HttpResponse httpResponse) throws IOException {
setHttpResponse(httpResponse);
HttpEntity entity = httpResponse.getEntity();
String charset = EntityUtils.getContentCharSet(entity);
if(charset == null) {
charset = HTTP.DEFAULT_CONTENT_CHARSET;
}
setContent(EntityUtils.toByteArray(entity));
setContentAsString(new String(content, charset));
EntityUtils.consume(entity);
}
// Speichert die Datei
public void saveContent(String fileName, byte[] content) throws HttpCommunicationException {
OutputStream out = null;
try {
File file = new File(getConfiguration().getDirectory(), fileName);
out = new FileOutputStream(file);
out.write(content);
System.out.println(content.length + " Bytes geschrieben in " + file.getAbsolutePath());
} catch (FileNotFoundException ex) {
throw new HttpCommunicationException(ex);
} catch (IOException ex) {
throw new HttpCommunicationException(ex);
} finally {
try {
if (out != null) {
out.close();
}
} catch (IOException ex) {
throw new HttpCommunicationException(ex);
}
}
}