publicclassDownload{privateHttpClienthttpCliente;privateHttpResponsehttpResponse;privateHttpGethttpGet;privateHttpEntityhttpEntity;privateByteArrayOutputStreamoutBytes;privatestaticfinalStringLINK="http://www1.caixa.gov.br/loterias/_arquivos/loterias/D_quina.zip";privateByteArrayOutputStreamdownloadZip(Stringlink){httpCliente=newDefaultHttpClient();httpGet=newHttpGet(link);outBytes=newByteArrayOutputStream();try{httpResponse=httpCliente.execute(httpGet);httpEntity=httpResponse.getEntity();if(httpEntity!=null){httpEntity.writeTo(outBytes);outBytes.close();}}catch(IOExceptionex){}returnoutBytes;}publicstaticvoidmain(String[]args){Filearq=newFile("C:\\Users\\andy11x\\Desktop\\quina.zip");FileOutputStreamfos=null;byte[]arqBytes=newDownload().downloadZip(LINK).toByteArray();try{if(!arq.exists()){fos=newFileOutputStream(arq);fos.write(arqBytes);fos.close();}}catch(Exceptionex){}//Gera FileNotFoundException e um IOException}}
M
mmx
Obrigado pela atenção ! vou executar o exemplo aqui e depois eu posto o resultado
M
mmx
legal ! funcionou, só precisei modificar o seguinte