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.FiledestinationDestination.private booleanrenameEmptyFilesIf true, rename empty files, otherwise delete empty files.private java.io.FilesourceSource.-
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 booleanexecute()Rename file.static booleanexecute(java.io.File source, java.io.File destination, boolean renameEmptyFiles)Rename file.java.io.FilegetDestination()Gets the destination.java.io.FilegetSource()Gets the source.booleanisRenameEmptyFiles()Whether to rename empty files.private static booleanmoveFile(java.nio.file.Path source, java.nio.file.Path target)java.lang.StringtoString()-
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:
executein interfaceAction- Specified by:
executein 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:
toStringin classjava.lang.Object
-
-