1 8 package org.jivesoftware.util.log.output.io.rotate; 9 10 import java.io.File ; 11 12 25 public class ExpandingFileStrategy implements FileStrategy { 26 27 private String baseFileName; 29 30 public ExpandingFileStrategy(final String baseFileName) { 31 32 this.baseFileName = baseFileName; 33 } 34 35 public File currentFile() { 36 return new File (baseFileName); 37 } 38 39 44 public File nextFile() { 45 for (int i = 0; true; i++) { 47 File test = new File (baseFileName.substring(0, baseFileName.lastIndexOf('.')) + 48 "_" + i + baseFileName.substring(baseFileName.lastIndexOf('.'))); 49 50 if (test.exists()) { 51 continue; 52 } 53 else { 54 return test; 55 } 56 } 57 } 58 } 59 60 | Popular Tags |