1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
//Appel du webservice pour récupérer fichier
byte[] recep = stubrpc.statutDeclaration(numDepot);
int fileSize =recep.length;
//Enregistrement du fichier reçu en local
try {
File file = new File("C:/recep.zip");
FileOutputStream foStream = new FileOutputStream(file);
try{
ByteArrayOutputStream destinationFile = new ByteArrayOutputStream();
ByteArrayInputStream sourceFile = new ByteArrayInputStream(recep);
try{
int nbLecture;
byte buffer[]=new byte[512*1024];
while( (nbLecture = sourceFile.read(buffer)) != -1 ) {
destinationFile.write(buffer, 0, nbLecture);
destinationFile.writeTo(foStream);
}
}finally { destinationFile.close(); }
} finally { foStream.close(); }
} catch (IOException e) {
e.printStackTrace();
} |