Class FileRenameAction
- java.lang.Object
-
- org.apache.logging.log4j.core.appender.rolling.action.AbstractAction
-
- org.apache.logging.log4j.core.appender.rolling.action.FileRenameAction
-
- All Implemented Interfaces:
java.lang.Runnable
,Action
public class FileRenameAction extends AbstractAction
File rename action.
-
-
Field Summary
Fields Modifier and Type Field Description private java.io.File
destination
Destination.private boolean
renameEmptyFiles
If true, rename empty files, otherwise delete empty files.private java.io.File
source
Source.-
Fields inherited from class org.apache.logging.log4j.core.appender.rolling.action.AbstractAction
LOGGER
-
-
Constructor Summary
Constructors Constructor Description FileRenameAction(java.io.File src, java.io.File dst, boolean renameEmptyFiles)
Creates an FileRenameAction.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
execute()
Rename file.static boolean
execute(java.io.File source, java.io.File destination, boolean renameEmptyFiles)
Rename file.java.io.File
getDestination()
Gets the destination.java.io.File
getSource()
Gets the source.boolean
isRenameEmptyFiles()
Whether to rename empty files.private static boolean
moveFile(java.nio.file.Path source, java.nio.file.Path target)
java.lang.String
toString()
-
Methods inherited from class org.apache.logging.log4j.core.appender.rolling.action.AbstractAction
close, isComplete, isInterrupted, reportException, run
-
-
-
-
Method Detail
-
execute
public boolean execute()
Rename file.- Specified by:
execute
in interfaceAction
- Specified by:
execute
in classAbstractAction
- Returns:
- true if successfully renamed.
-
getDestination
public java.io.File getDestination()
Gets the destination.- Returns:
- the destination.
-
getSource
public java.io.File getSource()
Gets the source.- Returns:
- the source.
-
isRenameEmptyFiles
public boolean isRenameEmptyFiles()
Whether to rename empty files. If true, rename empty files, otherwise delete empty files.- Returns:
- Whether to rename empty files.
-
execute
public static boolean execute(java.io.File source, java.io.File destination, boolean renameEmptyFiles)
Rename file.- Parameters:
source
- current file name.destination
- new file name.renameEmptyFiles
- if true, rename file even if empty, otherwise delete empty files.- Returns:
- true if successfully renamed.
-
moveFile
private static boolean moveFile(java.nio.file.Path source, java.nio.file.Path target) throws java.io.IOException
- Throws:
java.io.IOException
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-