@Override public void onComplete(Exchange exchange) { FileUtil.deleteFile(this.fileToDelete); } }
@Override public void onComplete(Exchange exchange) { LOG.debug("Deleting tar file on completion: {}", this.fileToDelete); FileUtil.deleteFile(this.fileToDelete); } }
private void addFileToTar(File source, File file, String fileName) throws IOException, ArchiveException { File tmpTar = File.createTempFile(source.getName(), null, parentDir); tmpTar.delete(); if (!source.renameTo(tmpTar)) { throw new IOException("Could not make temp file (" + source.getName() + ")"); } FileInputStream fis = new FileInputStream(tmpTar); TarArchiveInputStream tin = (TarArchiveInputStream) new ArchiveStreamFactory().createArchiveInputStream(ArchiveStreamFactory.TAR, fis); TarArchiveOutputStream tos = new TarArchiveOutputStream(new FileOutputStream(source)); tos.setLongFileMode(TarArchiveOutputStream.LONGFILE_POSIX); tos.setBigNumberMode(TarArchiveOutputStream.BIGNUMBER_POSIX); InputStream in = new FileInputStream(file); // copy the existing entries ArchiveEntry nextEntry; while ((nextEntry = tin.getNextEntry()) != null) { tos.putArchiveEntry(nextEntry); IOUtils.copy(tin, tos); tos.closeArchiveEntry(); } // Add the new entry TarArchiveEntry entry = new TarArchiveEntry(fileName == null ? file.getName() : fileName); entry.setSize(file.length()); tos.putArchiveEntry(entry); IOUtils.copy(in, tos); tos.closeArchiveEntry(); IOHelper.close(fis, in, tin, tos); LOG.trace("Deleting temporary file: {}", tmpTar); FileUtil.deleteFile(tmpTar); }
private void addEntryToTar(File source, String entryName, byte[] buffer, int length) throws IOException, ArchiveException { File tmpTar = File.createTempFile(source.getName(), null, parentDir); tmpTar.delete(); if (!source.renameTo(tmpTar)) { throw new IOException("Cannot create temp file: " + source.getName()); } FileInputStream fis = new FileInputStream(tmpTar); TarArchiveInputStream tin = (TarArchiveInputStream) new ArchiveStreamFactory().createArchiveInputStream(ArchiveStreamFactory.TAR, fis); TarArchiveOutputStream tos = new TarArchiveOutputStream(new FileOutputStream(source)); tos.setLongFileMode(TarArchiveOutputStream.LONGFILE_POSIX); tos.setBigNumberMode(TarArchiveOutputStream.BIGNUMBER_POSIX); // copy the existing entries ArchiveEntry nextEntry; while ((nextEntry = tin.getNextEntry()) != null) { tos.putArchiveEntry(nextEntry); IOUtils.copy(tin, tos); tos.closeArchiveEntry(); } // Create new entry TarArchiveEntry entry = new TarArchiveEntry(entryName); entry.setSize(length); tos.putArchiveEntry(entry); tos.write(buffer, 0, length); tos.closeArchiveEntry(); IOHelper.close(fis, tin, tos); LOG.trace("Deleting temporary file: {}", tmpTar); FileUtil.deleteFile(tmpTar); }
if (!FileUtil.deleteFile(temp)) { throw new GenericFileOperationFailedException("Cannot delete existing local work file: " + temp); if (!FileUtil.deleteFile(local)) { throw new GenericFileOperationFailedException("Cannot delete existing local work file: " + local); boolean deleted = FileUtil.deleteFile(temp); if (!deleted) { LOG.warn("Error occurred during retrieving file: " + name + " to local directory. Cannot delete local work file: " + temp);
if (!FileUtil.deleteFile(local)) { throw new GenericFileOperationFailedException("Cannot delete existing local work file: " + local); if (exists && !FileUtil.deleteFile(temp)) { throw new GenericFileOperationFailedException("Cannot delete existing local work file: " + temp); boolean deleted = FileUtil.deleteFile(temp); if (!deleted) { log.warn("Error occurred during retrieving file: " + name + " to local directory. Cannot delete local work file: " + temp);
FileUtil.deleteFile(filePayload);
FileUtil.deleteFile(filePayload);