Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (101)
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 (309)
Collections:
Other Resources:
What Is commons-io-2.11.jar
What Is commons-io-2.11.jar?
✍: FYIcenter.com
commons-io-2.11.jar is the JAR file for Commons IO 2.5,
which is a library of utilities to assist with developing IO functionality.
JAR File Size and Download Location:
JAR name: commons-io-2.11.0.jar Target JDK version: 8 Dependency: None File name: commons-io.jar, commons-io-2.11.0.jar File size: 327135 bytes Release date: 01-22-2020 Download: Apache Commons IO Website
Java source code files for commons-io-2.11.jar are:
⏎ 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.IOException; import java.io.Serializable; import java.nio.file.FileVisitResult; import java.nio.file.Path; import java.nio.file.attribute.BasicFileAttributes; import java.util.Date; import org.apache.commons.io.FileUtils; import org.apache.commons.io.file.PathUtils; /** * 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: * </p> * <h2>Using Classic IO</h2> * <pre> * Path dir = Paths.get(""); * // 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 (String file : files) { * System.out.println(file); * } * </pre> * * <h2>Using NIO</h2> * <pre> * Path dir = Paths.get(""); * // We are interested in files older than one day * long cutoff = System.currentTimeMillis() - (24 * 60 * 60 * 1000); * AccumulatorPathVisitor visitor = AccumulatorPathVisitor.withLongCounters(new AgeFileFilter(cutoff)); * // * // Walk one dir * Files.<b>walkFileTree</b>(dir, Collections.emptySet(), 1, visitor); * System.out.println(visitor.getPathCounters()); * System.out.println(visitor.getFileList()); * // * visitor.getPathCounters().reset(); * // * // Walk dir tree * Files.<b>walkFileTree</b>(dir, visitor); * System.out.println(visitor.getPathCounters()); * System.out.println(visitor.getDirList()); * System.out.println(visitor.getFileList()); * </pre> * * @see FileFilterUtils#ageFileFilter(Date) * @see FileFilterUtils#ageFileFilter(File) * @see FileFilterUtils#ageFileFilter(long) * @see FileFilterUtils#ageFileFilter(Date, boolean) * @see FileFilterUtils#ageFileFilter(File, boolean) * @see FileFilterUtils#ageFileFilter(long, boolean) * @since 1.2 */ public class AgeFileFilter extends AbstractFileFilter implements Serializable { private static final long serialVersionUID = -2132740084016138541L; /** Whether the files accepted will be older or newer. */ private final boolean acceptOlder; /** The cutoff time threshold measured in milliseconds since the epoch (00:00:00 GMT, January 1, 1970). */ private final long cutoffMillis; /** * 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(final 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(final Date cutoffDate, final 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 used as the threshold age of the files */ public AgeFileFilter(final 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 used 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(final File cutoffReference, final boolean acceptOlder) { this(FileUtils.lastModifiedUnchecked(cutoffReference), acceptOlder); } /** * Constructs a new age file filter for files equal to or older than a certain cutoff * * @param cutoffMillis The cutoff time threshold measured in milliseconds since the epoch (00:00:00 GMT, January 1, * 1970). */ public AgeFileFilter(final long cutoffMillis) { this(cutoffMillis, true); } /** * Constructs a new age file filter for files on any one side of a certain cutoff. * * @param cutoffMillis The cutoff time threshold measured in milliseconds since the epoch (00:00:00 GMT, January 1, * 1970). * @param acceptOlder if true, older files (at or before the cutoff) are accepted, else newer ones (after the * cutoff). */ public AgeFileFilter(final long cutoffMillis, final boolean acceptOlder) { this.acceptOlder = acceptOlder; this.cutoffMillis = cutoffMillis; } /** * 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. * </p> * * @param file the File to check * @return true if the file name matches */ @Override public boolean accept(final File file) { final boolean newer = FileUtils.isFileNewer(file, cutoffMillis); return acceptOlder != newer; } /** * 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. * </p> * @param file the File to check * * @return true if the file name matches * @since 2.9.0 */ @Override public FileVisitResult accept(final Path file, final BasicFileAttributes attributes) { final boolean newer; try { newer = PathUtils.isNewer(file, cutoffMillis); } catch (final IOException e) { return handle(e); } return toFileVisitResult(acceptOlder != newer, file); } /** * Provide a String representation of this file filter. * * @return a String representation */ @Override public String toString() { final String condition = acceptOlder ? "<=" : ">"; return super.toString() + "(" + condition + cutoffMillis + ")"; } }
⏎ org/apache/commons/io/filefilter/AgeFileFilter.java
Or download all of them as a single archive file:
File name: commons-io-2.11.0-sources.jar File size: 398939 bytes Release date: 2020-01-22 Download
⇒ Download and Install commons-io-2.6-bin.zip
⇐ What Is commons-io-2.11-bin.zip
2022-11-10, 68980👍, 2💬
Popular Posts:
layout.jar is a component in iText Java library to provide layout functionalities. iText Java librar...
What JAR files are required to run dom\Counter.java provided in the Apache Xerces package? You can f...
XOM™ is a new XML object model. It is an open source (LGPL), tree-based API for processing XML with ...
iText is an ideal library for developers looking to enhance web- and other applications with dynamic...
XMLSchema, Release 1.4.2, is a lightweight Java object model that can be used to manipulate and gene...