Klasse RollingFileUtil

java.lang.Object
com.github.hypfvieh.files.RollingFileUtil

public class RollingFileUtil extends Object
Class to provide a simple file name rollover feature.

The output file name is specified by a file name pattern.

Supported placeholders are
 %{n} ⇒ replaced by current number of file
 %{ext} ⇒ extension of the file without leading dot
 %{date:PATTERN} ⇒ use date/time as pattern, where PATTERN is a valid DateTimeFormatter pattern
 
Every pattern has to specify exactly one %{n}-placeholder which will be replaced by the current
number of files. Providing no %{n} placeholder or more than one will throw IllegalArgumentException.

Older files will be moved to a new name until the given maximum of files is reached.
When maximum is reached, the oldest file will be removed and all other files will be renamed.

The newest file will always have the lowest number.
Seit:
v1.0.6 - 2019-04-29
Autor:
hypfvieh
  • Konstruktordetails

    • RollingFileUtil

      public RollingFileUtil()
  • Methodendetails

    • doFileRolling

      public static File doFileRolling(File _fileToRollOver, String _pattern, int _maxFiles) throws IOException
      Do a rollover of the given source file using the provided pattern.
      Parameter:
      _fileToRollOver - file to roll over
      _pattern - pattern of the target file
      _maxFiles - maximum amount of files created before deleting
      Gibt zurück:
      File object with the new name of the given source, null on error
      Löst aus:
      IOException - if moving fails