1 21 22 package org.opensubsystems.core.util; 23 24 import java.io.File ; 25 import java.io.FilenameFilter ; 26 import java.util.Date ; 27 28 37 public class MaximumFileFilter implements FilenameFilter 38 { 39 41 44 protected int m_currentFileCount = 0; 45 46 49 50 protected int m_iMaximum = 0; 51 52 56 protected Date m_dtOlderThan; 57 58 60 68 69 public MaximumFileFilter( 70 int iMax, 71 Date dtOlderThen 72 ) 73 { 74 m_iMaximum = iMax; 75 m_dtOlderThan = dtOlderThen; 76 } 77 78 81 public boolean accept( 82 File dir, 83 String name 84 ) 85 { 86 File currentFile = new File (dir, name); 87 88 if (currentFile.isDirectory()) 89 { 90 return false; 91 } 92 if ((m_dtOlderThan != null) && (currentFile.lastModified() > m_dtOlderThan.getTime())) 93 { 94 return false; 95 } 96 if ((m_iMaximum == 0) || (m_currentFileCount <= m_iMaximum)) 97 { 98 m_currentFileCount++; 99 } 100 return m_currentFileCount <= m_iMaximum; 101 } 102 } 103 104 | Popular Tags |