Class CommonsCompressAction
- java.lang.Object
-
- org.apache.logging.log4j.core.appender.rolling.action.AbstractAction
-
- org.apache.logging.log4j.core.appender.rolling.action.CommonsCompressAction
-
public final class CommonsCompressAction extends AbstractAction
Compresses a file using bzip2 compression.
-
-
Field Summary
-
Fields inherited from class org.apache.logging.log4j.core.appender.rolling.action.AbstractAction
LOGGER
-
-
Constructor Summary
Constructors Constructor Description CommonsCompressAction(String name, File source, File destination, boolean deleteSource)
Creates new instance of Bzip2CompressAction.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
execute()
Compresses.static boolean
execute(String name, File source, File destination, boolean deleteSource)
Compresses a file.File
getDestination()
String
getName()
File
getSource()
boolean
isDeleteSource()
protected void
reportException(Exception ex)
Reports exception.String
toString()
-
Methods inherited from class org.apache.logging.log4j.core.appender.rolling.action.AbstractAction
close, isComplete, isInterrupted, run
-
-
-
-
Constructor Detail
-
CommonsCompressAction
public CommonsCompressAction(String name, File source, File destination, boolean deleteSource)
Creates new instance of Bzip2CompressAction.- Parameters:
name
- the compressor name. One of "gz", "bzip2", "xz", "pack200", or "deflate".source
- file to compress, may not be null.destination
- compressed file, may not be null.deleteSource
- if true, attempt to delete file on completion. Failure to delete does not cause an exception to be thrown or affect return value.
-
-
Method Detail
-
execute
public boolean execute() throws IOException
Compresses.- Specified by:
execute
in interfaceAction
- Specified by:
execute
in classAbstractAction
- Returns:
- true if successfully compressed.
- Throws:
IOException
- on IO exception.
-
execute
public static boolean execute(String name, File source, File destination, boolean deleteSource) throws IOException
Compresses a file.- Parameters:
name
- the compressor name, i.e. "gz", "bzip2", "xz", "pack200", or "deflate".source
- file to compress, may not be null.destination
- compressed file, may not be null.deleteSource
- if true, attempt to delete file on completion. Failure to delete does not cause an exception to be thrown or affect return value.- Returns:
- true if source file compressed.
- Throws:
IOException
- on IO exception.
-
reportException
protected void reportException(Exception ex)
Reports exception.- Overrides:
reportException
in classAbstractAction
- Parameters:
ex
- exception.
-
getName
public String getName()
-
getSource
public File getSource()
-
getDestination
public File getDestination()
-
isDeleteSource
public boolean isDeleteSource()
-
-