@Test public void testNoSource() throws Exception { try { CompressBackupUtil.tar(new File(randName + ".txt"), dest); } catch (IllegalArgumentException e) { return; } Assert.fail("No source file/folder exists. Should have thrown an exception."); }
public static void tar(@NotNull File source, @NotNull File dest) throws IOException { if (!source.exists()) { throw new IllegalArgumentException("No source file or folder exists: " + source.getAbsolutePath()); } if (dest.exists()) { throw new IllegalArgumentException("Destination refers to existing file or folder: " + dest.getAbsolutePath()); } try (TarArchiveOutputStream tarOut = new TarArchiveOutputStream(new GZIPOutputStream( new BufferedOutputStream(new FileOutputStream(dest)), 0x1000))) { doTar("", source, tarOut); } catch (IOException e) { IOUtil.deleteFile(dest); throw e; } }
CompressBackupUtil { public static void tar(@NotNull File source, @NotNull File dest) throws IOException { if (!source.exists()) { throw new IllegalArgumentException("No source file or folder exists: " + source.getAbsolutePath()); } if (dest.exists()) { throw new IllegalArgumentException("Destination refers to existing file or folder: " + dest.getAbsolutePath()); } try (TarArchiveOutputStream tarOut = new TarArchiveOutputStream(new GZIPOutputStream( new BufferedOutputStream(new FileOutputStream(dest)), 0x1000))) { doTar("", source, tarOut); } catch (IOException e) { IOUtil.deleteFile(dest); throw e; } } }
CompressBackupUtil { public static void tar(@NotNull File source, @NotNull File dest) throws IOException { if (!source.exists()) { throw new IllegalArgumentException("No source file or folder exists: " + source.getAbsolutePath()); } if (dest.exists()) { throw new IllegalArgumentException("Destination refers to existing file or folder: " + dest.getAbsolutePath()); } try (TarArchiveOutputStream tarOut = new TarArchiveOutputStream(new GZIPOutputStream( new BufferedOutputStream(new FileOutputStream(dest)), 0x1000))) { doTar("", source, tarOut); } catch (IOException e) { IOUtil.deleteFile(dest); throw e; } } private  CompressBackupUtil(); }
CompressBackupUtil { public static void tar(@NotNull File source, @NotNull File dest) throws IOException { if (!source.exists()) { throw new IllegalArgumentException("No source file or folder exists: " + source.getAbsolutePath()); } if (dest.exists()) { throw new IllegalArgumentException("Destination refers to existing file or folder: " + dest.getAbsolutePath()); } try (TarArchiveOutputStream tarOut = new TarArchiveOutputStream(new GZIPOutputStream( new BufferedOutputStream(new FileOutputStream(dest)), 0x1000))) { doTar("", source, tarOut); } catch (IOException e) { IOUtil.deleteFile(dest); throw e; } } private  CompressBackupUtil(); @NotNull static File backup(@NotNull final Backupable source, @NotNull final File backupRoot,
                              @Nullable final String backupNamePrefix, final boolean zip); @NotNull static File backup(@NotNull final BackupBean backupBean); @NotNull static File backup(@NotNull final Backupable source,
                              @NotNull final File target, final boolean zip); @NotNull static String getTimeStampedTarGzFileName(); @NotNull static String getTimeStampedZipFileName(); static void tar(@NotNull File source, @NotNull File dest); static void archiveFile(@NotNull final ArchiveOutputStream out,
                                   @NotNull final VirtualFileDescriptor source,
                                   final long fileSize); }
CompressBackupUtil { public static void tar(@NotNull File source, @NotNull File dest) throws IOException { if (!source.exists()) { throw new IllegalArgumentException("No source file or folder exists: " + source.getAbsolutePath()); } if (dest.exists()) { throw new IllegalArgumentException("Destination refers to existing file or folder: " + dest.getAbsolutePath()); } try (TarArchiveOutputStream tarOut = new TarArchiveOutputStream(new GZIPOutputStream( new BufferedOutputStream(new FileOutputStream(dest)), 0x1000))) { doTar("", source, tarOut); } catch (IOException e) { IOUtil.deleteFile(dest); throw e; } } private  CompressBackupUtil(); @NotNull static File backup(@NotNull final Backupable source, @NotNull final File backupRoot,
                              @Nullable final String backupNamePrefix, final boolean zip); @NotNull static File backup(@NotNull final BackupBean backupBean); @NotNull static File backup(@NotNull final Backupable source,
                              @NotNull final File target, final boolean zip); @NotNull static String getTimeStampedTarGzFileName(); @NotNull static String getTimeStampedZipFileName(); static void tar(@NotNull File source, @NotNull File dest); static void archiveFile(@NotNull final ArchiveOutputStream out,
                                   @NotNull final VirtualFileDescriptor source,
                                   final long fileSize);  }