Package hec.util

Class LogFileNamer

java.lang.Object
hec.util.LogFileNamer
All Implemented Interfaces:
LogTimeIntervals, TimeIntervals

public class LogFileNamer extends Object implements LogTimeIntervals
  • Constructor Details

    • LogFileNamer

      public LogFileNamer(String directory, String baseFileName, String timeInterval, boolean localTime)
  • Method Details

    • setOut

      public void setOut(FileOutputStream out)
    • isValidTimeInterval

      public boolean isValidTimeInterval()
    • getTimeForNextFile

      public long getTimeForNextFile()
    • getNewFilename

      public String getNewFilename(long currentTime) throws IOException
      Throws:
      IOException
    • generateLogFileName

      public static String generateLogFileName(String subdirectory, String baseFileName, String initialPath)
      Generate a log file name in the temp directory with collision avoidance. If the file exists and cannot be deleted (e.g., another instance is using it), automatically sequences to numbered alternatives (0-99).
      Parameters:
      subdirectory - Optional subdirectory under java.io.tmpdir (null for none)
      baseFileName - Base name for the log file (without .log extension)
      initialPath - Optional full path to try first (if null, uses baseFileName)
      Returns:
      Full path to an available log file
    • generateLogFileName

      public static String generateLogFileName(String baseFileName)
      Generate a log file name in the temp directory with collision avoidance. If the file exists and cannot be deleted (e.g., another instance is using it), automatically sequences to numbered alternatives (0-99).
      Parameters:
      baseFileName - Base name for the log file (without .log extension)
      Returns:
      Full path to an available log file