Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (102)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (322)
Collections:
Other Resources:
commons-io-1.4.jar - Apache Commons IO
commons-io-1.4.jar is the JAR file for Commons IO 1.4,
which is a library of utilities to assist with developing IO functionality.
JAR File Size and Download Location:
JAR name: commons-io.jar, commons-io-1.4.jar Target JDK version: 1.3 Dependency: None File size: 109043 bytes Date modified: 16-Jan-2008 Download: Apache Commons IO Website
✍: FYIcenter.com
⏎ org/apache/commons/io/filefilter/AgeFileFilter.java
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.io.filefilter;
import java.io.File;
import java.io.Serializable;
import java.util.Date;
import org.apache.commons.io.FileUtils;
/**
* Filters files based on a cutoff time, can filter either newer
* files or files equal to or older.
* <p>
* For example, to print all files and directories in the
* current directory older than one day:
*
* <pre>
* File dir = new File(".");
* // We are interested in files older than one day
* long cutoff = System.currentTimeMillis() - (24 * 60 * 60 * 1000);
* String[] files = dir.list( new AgeFileFilter(cutoff) );
* for ( int i = 0; i < files.length; i++ ) {
* System.out.println(files[i]);
* }
* </pre>
*
* @author Rahul Akolkar
* @version $Id: AgeFileFilter.java 606381 2007-12-22 02:03:16Z ggregory $
* @since Commons IO 1.2
*/
public class AgeFileFilter extends AbstractFileFilter implements Serializable {
/** The cutoff time threshold. */
private final long cutoff;
/** Whether the files accepted will be older or newer. */
private final boolean acceptOlder;
/**
* Constructs a new age file filter for files equal to or older than
* a certain cutoff
*
* @param cutoff the threshold age of the files
*/
public AgeFileFilter(long cutoff) {
this(cutoff, true);
}
/**
* Constructs a new age file filter for files on any one side
* of a certain cutoff.
*
* @param cutoff the threshold age of the files
* @param acceptOlder if true, older files (at or before the cutoff)
* are accepted, else newer ones (after the cutoff).
*/
public AgeFileFilter(long cutoff, boolean acceptOlder) {
this.acceptOlder = acceptOlder;
this.cutoff = cutoff;
}
/**
* Constructs a new age file filter for files older than (at or before)
* a certain cutoff date.
*
* @param cutoffDate the threshold age of the files
*/
public AgeFileFilter(Date cutoffDate) {
this(cutoffDate, true);
}
/**
* Constructs a new age file filter for files on any one side
* of a certain cutoff date.
*
* @param cutoffDate the threshold age of the files
* @param acceptOlder if true, older files (at or before the cutoff)
* are accepted, else newer ones (after the cutoff).
*/
public AgeFileFilter(Date cutoffDate, boolean acceptOlder) {
this(cutoffDate.getTime(), acceptOlder);
}
/**
* Constructs a new age file filter for files older than (at or before)
* a certain File (whose last modification time will be used as reference).
*
* @param cutoffReference the file whose last modification
* time is usesd as the threshold age of the files
*/
public AgeFileFilter(File cutoffReference) {
this(cutoffReference, true);
}
/**
* Constructs a new age file filter for files on any one side
* of a certain File (whose last modification time will be used as
* reference).
*
* @param cutoffReference the file whose last modification
* time is usesd as the threshold age of the files
* @param acceptOlder if true, older files (at or before the cutoff)
* are accepted, else newer ones (after the cutoff).
*/
public AgeFileFilter(File cutoffReference, boolean acceptOlder) {
this(cutoffReference.lastModified(), acceptOlder);
}
//-----------------------------------------------------------------------
/**
* Checks to see if the last modification of the file matches cutoff
* favorably.
* <p>
* If last modification time equals cutoff and newer files are required,
* file <b>IS NOT</b> selected.
* If last modification time equals cutoff and older files are required,
* file <b>IS</b> selected.
*
* @param file the File to check
* @return true if the filename matches
*/
public boolean accept(File file) {
boolean newer = FileUtils.isFileNewer(file, cutoff);
return acceptOlder ? !newer : newer;
}
/**
* Provide a String representaion of this file filter.
*
* @return a String representaion
*/
public String toString() {
String condition = acceptOlder ? "<=" : ">";
return super.toString() + "(" + condition + cutoff + ")";
}
}
⏎ org/apache/commons/io/filefilter/AgeFileFilter.java
Or download all of them as a single archive file:
File name: commons-io-1.4-sources.jar File size: 280834 bytes Release date: 2008-01-16 Download
⇒ Using commons-io.jar in Java Code
2018-10-27, ≈72🔥, 0💬
Popular Posts:
maven-model-builder-3.5. 4.jaris the JAR file for Apache Maven 3.5.4 Model Builder module. Apache Ma...
What Is XMLBeans xbean.jar 2.6.0? XMLBeans xbean.jar 2.6.0 is the JAR file for Apache XMLBeans 2.6.0...
Jackson is "the Java JSON library" or "the best JSON parser for Java". Or simply as "JSON for Java"....
Apache Ant Source Code Files are inside the Apache Ant source package file like apache-ant-1.10.10-s...
How to read XML document with XML Schema validation from socket connections with the socket\DelayedI...