public class TarUtils extends Object
Modifier and Type | Field and Description |
---|---|
static int |
BUFFER_SIZE
The buffer size.
|
Constructor and Description |
---|
TarUtils()
Empty default constructor
|
Modifier and Type | Method and Description |
---|---|
static void |
addFolderContent(org.apache.commons.compress.archivers.ArchiveOutputStream tarOutput,
File folder,
WaitingHandler waitingHandler)
Add content to the tar file.
|
static void |
extractFile(File tarFile,
File destinationFolder,
WaitingHandler waitingHandler)
Extracts files from a tar.
|
static void |
extractFile(File tarFile,
WaitingHandler waitingHandler)
Extracts files from a tar.
|
static void |
tarFolder(File folder,
File destinationFile,
WaitingHandler waitingHandler)
Tar a given folder to a file.
|
static void |
tarFolderContent(File folder,
File destinationFile,
HashSet<String> exceptionsPaths,
WaitingHandler waitingHandler)
Tar the content of a given folder to a file.
|
public static final int BUFFER_SIZE
public static void tarFolder(File folder, File destinationFile, WaitingHandler waitingHandler) throws org.apache.commons.compress.archivers.ArchiveException, IOException
folder
- The original folder to tar.destinationFile
- The destination file.waitingHandler
- A waiting handler used to cancel the process (can
be null).org.apache.commons.compress.archivers.ArchiveException
- Thrown whenever an error occurred while taring.IOException
- Thrown whenever an error occurred while
reading/writing files.public static void tarFolderContent(File folder, File destinationFile, HashSet<String> exceptionsPaths, WaitingHandler waitingHandler) throws org.apache.commons.compress.archivers.ArchiveException, IOException
folder
- the original folder to tardestinationFile
- the destination fileexceptionsPaths
- a list of paths to files or folders which should
be excluded from taringwaitingHandler
- a waiting handler used to cancel the process (can
be null)org.apache.commons.compress.archivers.ArchiveException
- exception thrown whenever an error occurred
while taringIOException
- exception thrown whenever an error occurred while
reading/writing filespublic static void addFolderContent(org.apache.commons.compress.archivers.ArchiveOutputStream tarOutput, File folder, WaitingHandler waitingHandler) throws IOException
tarOutput
- the archive output streamfolder
- the folder to addwaitingHandler
- a waiting handler used to cancel the process (can
be null)IOException
- exception thrown whenever an error occurred while
reading/writing filespublic static void extractFile(File tarFile, WaitingHandler waitingHandler) throws org.apache.commons.compress.archivers.ArchiveException, IOException
tarFile
- the tar filewaitingHandler
- a waiting handler displaying progress and allowing
canceling the processorg.apache.commons.compress.archivers.ArchiveException
- if an ArchiveException occursIOException
- if an IOException occurspublic static void extractFile(File tarFile, File destinationFolder, WaitingHandler waitingHandler) throws org.apache.commons.compress.archivers.ArchiveException, IOException
tarFile
- the tar filedestinationFolder
- the destination folder, if null the file will be
extracted according to the archive namewaitingHandler
- a waiting handler displaying progress and allowing
canceling the processorg.apache.commons.compress.archivers.ArchiveException
- if an ArchiveException occursIOException
- if an IOException occursCopyright © 2021. All rights reserved.