Search in sources :

Example 1 with TaskExecutionFailedException

use of org.pixmob.httpclient.demo.TaskExecutionFailedException in project httpclient by pixmob.

the class DownloadFileTask method doRun.

@Override
protected void doRun() throws Exception {
    final File imgFile = new File(getContext().getCacheDir(), "google_logo.png");
    imgFile.delete();
    final HttpClient hc = createClient();
    hc.get("http://www.google.fr/images/srpr/logo3w.png").to(imgFile).execute();
    if (!imgFile.exists() || imgFile.length() == 0) {
        throw new TaskExecutionFailedException("File download failed");
    }
}
Also used : TaskExecutionFailedException(org.pixmob.httpclient.demo.TaskExecutionFailedException) HttpClient(org.pixmob.httpclient.HttpClient) File(java.io.File)

Aggregations

File (java.io.File)1 HttpClient (org.pixmob.httpclient.HttpClient)1 TaskExecutionFailedException (org.pixmob.httpclient.demo.TaskExecutionFailedException)1