Package hec.util
Class LogFileNamer
java.lang.Object
hec.util.LogFileNamer
- All Implemented Interfaces:
LogTimeIntervals,TimeIntervals
-
Field Summary
Fields inherited from interface rma.util.TimeIntervals
DAY_TIME_INTERVAL, HOUR_TIME_INTERVAL, MINUTE_TIME_INTERVAL, MONTH_TIME_INTERVAL, TIME_INTERVALS, TIME_INTERVALS_DESC, WEEK_TIME_INTERVAL, YEAR_TIME_INTERVAL -
Constructor Summary
ConstructorsConstructorDescriptionLogFileNamer(String directory, String baseFileName, String timeInterval, boolean localTime) -
Method Summary
Modifier and TypeMethodDescriptionstatic StringgenerateLogFileName(String baseFileName) Generate a log file name in the temp directory with collision avoidance.static StringgenerateLogFileName(String subdirectory, String baseFileName, String initialPath) Generate a log file name in the temp directory with collision avoidance.getNewFilename(long currentTime) longbooleanvoidsetOut(FileOutputStream out)
-
Constructor Details
-
LogFileNamer
-
-
Method Details
-
setOut
-
isValidTimeInterval
public boolean isValidTimeInterval() -
getTimeForNextFile
public long getTimeForNextFile() -
getNewFilename
- 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
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
-