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/Counters.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.math.BigInteger;
import java.util.Objects;
/**
* Provides counters for files, directories, and sizes, as a visit proceeds.
*
* @since 2.7
*/
public class Counters {
/**
* Counts files, directories, and sizes, as a visit proceeds.
*/
private static class AbstractPathCounters implements PathCounters {
private final Counter byteCounter;
private final Counter directoryCounter;
private final Counter fileCounter;
/**
* Constructs a new instance.
*
* @param byteCounter the byte counter.
* @param directoryCounter the directory counter.
* @param fileCounter the file counter.
*/
protected AbstractPathCounters(final Counter byteCounter, final Counter directoryCounter,
final Counter fileCounter) {
this.byteCounter = byteCounter;
this.directoryCounter = directoryCounter;
this.fileCounter = fileCounter;
}
@Override
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof AbstractPathCounters)) {
return false;
}
final AbstractPathCounters other = (AbstractPathCounters) obj;
return Objects.equals(byteCounter, other.byteCounter)
&& Objects.equals(directoryCounter, other.directoryCounter)
&& Objects.equals(fileCounter, other.fileCounter);
}
@Override
public Counter getByteCounter() {
return byteCounter;
}
@Override
public Counter getDirectoryCounter() {
return directoryCounter;
}
/**
* Gets the count of visited files.
*
* @return the byte count of visited files.
*/
@Override
public Counter getFileCounter() {
return this.fileCounter;
}
@Override
public int hashCode() {
return Objects.hash(byteCounter, directoryCounter, fileCounter);
}
@Override
public void reset() {
byteCounter.reset();
directoryCounter.reset();
fileCounter.reset();
}
@Override
public String toString() {
return String.format("%,d files, %,d directories, %,d bytes", Long.valueOf(fileCounter.get()),
Long.valueOf(directoryCounter.get()), Long.valueOf(byteCounter.get()));
}
}
/**
* Counts using a BigInteger number.
*/
private static final class BigIntegerCounter implements Counter {
private BigInteger value = BigInteger.ZERO;
@Override
public void add(final long val) {
value = value.add(BigInteger.valueOf(val));
}
@Override
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof Counter)) {
return false;
}
final Counter other = (Counter) obj;
return Objects.equals(value, other.getBigInteger());
}
@Override
public long get() {
return value.longValueExact();
}
@Override
public BigInteger getBigInteger() {
return value;
}
@Override
public Long getLong() {
return Long.valueOf(value.longValueExact());
}
@Override
public int hashCode() {
return Objects.hash(value);
}
@Override
public void increment() {
value = value.add(BigInteger.ONE);
}
@Override
public String toString() {
return value.toString();
}
@Override
public void reset() {
value = BigInteger.ZERO;
}
}
/**
* Counts files, directories, and sizes, as a visit proceeds, using BigInteger numbers.
*/
private final static class BigIntegerPathCounters extends AbstractPathCounters {
/**
* Constructs a new initialized instance.
*/
protected BigIntegerPathCounters() {
super(Counters.bigIntegerCounter(), Counters.bigIntegerCounter(), Counters.bigIntegerCounter());
}
}
/**
* Counts using a number.
*/
public interface Counter {
/**
* Adds the given number to this counter.
*
* @param val the value to add.
*/
void add(long val);
/**
* Gets the counter as a long.
*
* @return the counter as a long.
*/
long get();
/**
* Gets the counter as a BigInteger.
*
* @return the counter as a BigInteger.
*/
BigInteger getBigInteger();
/**
* Gets the counter as a Long.
*
* @return the counter as a Long.
*/
Long getLong();
/**
* Adds one to this counter.
*/
void increment();
/**
* Resets this count to 0.
*/
default void reset() {
// binary compat, do nothing
}
}
/**
* Counts using a long number.
*/
private final static class LongCounter implements Counter {
private long value;
@Override
public void add(final long add) {
value += add;
}
@Override
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof Counter)) {
return false;
}
final Counter other = (Counter) obj;
return value == other.get();
}
@Override
public long get() {
return value;
}
@Override
public BigInteger getBigInteger() {
return BigInteger.valueOf(value);
}
@Override
public Long getLong() {
return Long.valueOf(value);
}
@Override
public int hashCode() {
return Objects.hash(value);
}
@Override
public void increment() {
value++;
}
@Override
public String toString() {
return Long.toString(value);
}
@Override
public void reset() {
value = 0L;
}
}
/**
* Counts files, directories, and sizes, as a visit proceeds, using long numbers.
*/
private final static class LongPathCounters extends AbstractPathCounters {
/**
* Constructs a new initialized instance.
*/
protected LongPathCounters() {
super(Counters.longCounter(), Counters.longCounter(), Counters.longCounter());
}
}
/**
* Counts nothing.
*/
private final static class NoopCounter implements Counter {
static final NoopCounter INSTANCE = new NoopCounter();
@Override
public void add(final long add) {
// noop
}
@Override
public long get() {
return 0;
}
@Override
public BigInteger getBigInteger() {
return BigInteger.ZERO;
}
@Override
public Long getLong() {
return 0L;
}
@Override
public void increment() {
// noop
}
}
/**
* Counts nothing.
*/
private static final class NoopPathCounters extends AbstractPathCounters {
static final NoopPathCounters INSTANCE = new NoopPathCounters();
/**
* Constructs a new initialized instance.
*/
private NoopPathCounters() {
super(Counters.noopCounter(), Counters.noopCounter(), Counters.noopCounter());
}
}
/**
* Counts files, directories, and sizes, as a visit proceeds.
*/
public interface PathCounters {
/**
* Gets the byte counter.
*
* @return the byte counter.
*/
Counter getByteCounter();
/**
* Gets the directory counter.
*
* @return the directory counter.
*/
Counter getDirectoryCounter();
/**
* Gets the file counter.
*
* @return the file counter.
*/
Counter getFileCounter();
/**
* Resets the counts to 0.
*/
default void reset() {
// binary compat, do nothing
}
}
/**
* Returns a new BigInteger Counter.
*
* @return a new BigInteger Counter.
*/
public static Counter bigIntegerCounter() {
return new BigIntegerCounter();
}
/**
* Returns a new BigInteger PathCounters.
*
* @return a new BigInteger PathCounters.
*/
public static PathCounters bigIntegerPathCounters() {
return new BigIntegerPathCounters();
}
/**
* Returns a new long Counter.
*
* @return a new long Counter.
*/
public static Counter longCounter() {
return new LongCounter();
}
/**
* Returns a new BigInteger PathCounters.
*
* @return a new BigInteger PathCounters.
*/
public static PathCounters longPathCounters() {
return new LongPathCounters();
}
/**
* Returns the NOOP Counter.
*
* @return the NOOP Counter.
* @since 2.9.0
*/
public static Counter noopCounter() {
return NoopCounter.INSTANCE;
}
/**
* Returns the NOOP PathCounters.
*
* @return the NOOP PathCounters.
* @since 2.9.0
*/
public static PathCounters noopPathCounters() {
return NoopPathCounters.INSTANCE;
}
}
⏎ org/apache/commons/io/file/Counters.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, ≈106🔥, 2💬
Popular Posts:
ANTLR is a powerful parser generator for multiple programming languages including Java. ANTLR contai...
XStream is a simple library to serialize objects to XML and back again. JAR File Size and Download L...
JDK 11 jdk.jdeps.jmod is the JMOD file for JDK 11 JDeps tool, which can be invoked by the "jdeps" co...
MP3SPI is a Java Service Provider Interface that adds MP3 (MPEG 1/2/2.5 Layer 1/2/3) audio format su...
JDK 11 java.xml.jmod is the JMOD file for JDK 11 XML (eXtensible Markup Language) module. JDK 11 XML...