- }
- if (payloadFile != null) {
- InputStream payloadInputStream = ((DirectFileEntry) fileEntry).getDataInputStream();
- FileOutputStream payloadOutputStream = null;
- try {
- payloadOutputStream = new FileOutputStream(payloadFile, true);
- byte[] buffer = new byte[65536];
- int read = 0;
- while ((read = payloadInputStream.read(buffer)) != -1) {
- payloadOutputStream.write(buffer, 0, read);
- System.out.println("writing " + read + " bytes");
+ if (payloadFile != null) {
+ InputStream payloadInputStream = ((DirectFileEntry) fileEntry).getDataInputStream();
+ FileOutputStream payloadOutputStream = null;
+ try {
+ payloadOutputStream = new FileOutputStream(payloadFile, true);
+ byte[] buffer = new byte[65536];
+ int read = 0;
+ while ((read = payloadInputStream.read(buffer)) != -1) {
+ payloadOutputStream.write(buffer, 0, read);
+ }
+ payloadOutputStream.flush();
+ fileEntries.add(fileEntry);
+ } catch (IOException ioe1) {
+ payloadFile.delete();
+ throw ioe1;
+ } finally {
+ Closer.close(payloadOutputStream);
+ Closer.close(payloadInputStream);