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:
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/file/AccumulatorPathVisitor.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.file;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;
import org.apache.commons.io.file.Counters.PathCounters;
/**
* Accumulates normalized paths during visitation.
* <p>
* Use with care on large file trees as each visited Path element is remembered.
* </p>
* <h2>Example</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.walkFileTree(dir, Collections.emptySet(), 1, visitor);
* System.out.println(visitor.getPathCounters());
* System.out.println(visitor.getFileList());
* //
* visitor.getPathCounters().reset();
* //
* // Walk dir tree
* Files.walkFileTree(dir, visitor);
* System.out.println(visitor.getPathCounters());
* System.out.println(visitor.getDirList());
* System.out.println(visitor.getFileList());
* </pre>
*
* @since 2.7
*/
public class AccumulatorPathVisitor extends CountingPathVisitor {
/**
* Creates a new instance configured with a BigInteger {@link PathCounters}.
*
* @return a new instance configured with a BigInteger {@link PathCounters}.
*/
public static AccumulatorPathVisitor withBigIntegerCounters() {
return new AccumulatorPathVisitor(Counters.bigIntegerPathCounters());
}
/**
* Creates a new instance configured with a BigInteger {@link PathCounters}.
*
* @param fileFilter Filters files to accumulate and count.
* @param dirFilter Filters directories to accumulate and count.
* @return a new instance configured with a long {@link PathCounters}.
* @since 2.9.0
*/
public static AccumulatorPathVisitor withBigIntegerCounters(final PathFilter fileFilter,
final PathFilter dirFilter) {
return new AccumulatorPathVisitor(Counters.bigIntegerPathCounters(), fileFilter, dirFilter);
}
/**
* Creates a new instance configured with a long {@link PathCounters}.
*
* @return a new instance configured with a long {@link PathCounters}.
*/
public static AccumulatorPathVisitor withLongCounters() {
return new AccumulatorPathVisitor(Counters.longPathCounters());
}
/**
* Creates a new instance configured with a long {@link PathCounters}.
*
* @param fileFilter Filters files to accumulate and count.
* @param dirFilter Filters directories to accumulate and count.
* @return a new instance configured with a long {@link PathCounters}.
* @since 2.9.0
*/
public static AccumulatorPathVisitor withLongCounters(final PathFilter fileFilter, final PathFilter dirFilter) {
return new AccumulatorPathVisitor(Counters.longPathCounters(), fileFilter, dirFilter);
}
private final List<Path> dirList = new ArrayList<>();
private final List<Path> fileList = new ArrayList<>();
/**
* Constructs a new instance.
*
* @since 2.9.0
*/
public AccumulatorPathVisitor() {
super(Counters.noopPathCounters());
}
/**
* Constructs a new instance that counts file system elements.
*
* @param pathCounter How to count path visits.
*/
public AccumulatorPathVisitor(final PathCounters pathCounter) {
super(pathCounter);
}
/**
* Constructs a new instance.
*
* @param pathCounter How to count path visits.
* @param fileFilter Filters which files to count.
* @param dirFilter Filters which directories to count.
* @since 2.9.0
*/
public AccumulatorPathVisitor(final PathCounters pathCounter, final PathFilter fileFilter,
final PathFilter dirFilter) {
super(pathCounter, fileFilter, dirFilter);
}
private void add(final List<Path> list, final Path dir) {
list.add(dir.normalize());
}
@Override
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (!super.equals(obj)) {
return false;
}
if (!(obj instanceof AccumulatorPathVisitor)) {
return false;
}
final AccumulatorPathVisitor other = (AccumulatorPathVisitor) obj;
return Objects.equals(dirList, other.dirList) && Objects.equals(fileList, other.fileList);
}
/**
* Gets the list of visited directories.
*
* @return the list of visited directories.
*/
public List<Path> getDirList() {
return dirList;
}
/**
* Gets the list of visited files.
*
* @return the list of visited files.
*/
public List<Path> getFileList() {
return fileList;
}
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + Objects.hash(dirList, fileList);
return result;
}
/**
* Relativizes each directory path with {@link Path#relativize(Path)} against the given {@code parent}, optionally
* sorting the result.
*
* @param parent A parent path
* @param sort Whether to sort
* @param comparator How to sort, null uses default sorting.
* @return A new list
*/
public List<Path> relativizeDirectories(final Path parent, final boolean sort,
final Comparator<? super Path> comparator) {
return PathUtils.relativize(getDirList(), parent, sort, comparator);
}
/**
* Relativizes each file path with {@link Path#relativize(Path)} against the given {@code parent}, optionally
* sorting the result.
*
* @param parent A parent path
* @param sort Whether to sort
* @param comparator How to sort, null uses default sorting.
* @return A new list
*/
public List<Path> relativizeFiles(final Path parent, final boolean sort,
final Comparator<? super Path> comparator) {
return PathUtils.relativize(getFileList(), parent, sort, comparator);
}
@Override
protected void updateDirCounter(final Path dir, final IOException exc) {
super.updateDirCounter(dir, exc);
add(dirList, dir);
}
@Override
protected void updateFileCounters(final Path file, final BasicFileAttributes attributes) {
super.updateFileCounters(file, attributes);
add(fileList, file);
}
}
⏎ org/apache/commons/io/file/AccumulatorPathVisitor.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, ≈109🔥, 2💬
Popular Posts:
How to read XML document with DTD validation from socket connections with the socket\DelayedInput.ja.. .
HttpComponents Core Source Code Files are provided in the source package file, httpcomponents-core-5...
JDK 11 jdk.internal.le.jmod is the JMOD file for JDK 11 Internal Line Editing module. JDK 11 Interna...
Apache Neethi provides general framework for the programmers to use WS Policy. It is compliant with ...
JDK 11 jdk.jfr.jmod is the JMOD file for JDK 11 JFR module. JDK 11 JFR module compiled class files a...