Questions tagged [apache-commons]

The Apache Commons project provides reusable, open source Java software components. Consider using a component specific tag (such as apache-commons-lang) rather than this general tag.

The Apache Commons is a project of the Apache Software Foundation and includes many components previously found in the retired Apache Jakarta Project. Apache Commons projects are gathered into three groups:

  • Apache Commons Proper is the group of Apache Commons components that are actively being supported by the Apache Commons community.

  • Apache Commons Sandbox is the group of proposed Apache Commons components that are in the process of building a community of users and developers. The sandbox serves the purpose of vetting proposed components for inclusion into Apache Commons. Once the whole Apache Commons community feels a sandbox component has gained a large enough following, the sandbox component can graduate to Apache Commons Proper

  • Apache Commons Dormant is a group of Apache Commons Components that are no longer in active development. There is little community support for these components and most likely will not be released.

For more information, visit the Apache Commons website to learn about the individual components as well as learn how to contribute.

1814 questions
19
votes
2 answers

Finding Log4J log file

I'm working on a project that uses Log4J via Commons. I'm trying to find the path to the log file, but I'm not finding an appropriate method that will return the logfile path from the Logger. Anyone ever attempted this?
wadesworld
  • 13,535
  • 14
  • 60
  • 93
19
votes
4 answers

Is there a Guava equivalent to Apache Commons CircularFifoBuffer?

I need a data structure that can efficiently buffer a specific number of elements, in FIFO order. As mentioned in this question, Apache Commons has a CircularFifoBuffer, but it is sadly not generified. Some forks exist, but I'm not sure of their…
Etienne Neveu
  • 12,604
  • 9
  • 36
  • 59
18
votes
2 answers

Google Play "Native platforms" showing commons-io-2.4.jar

I have just encountered a very weird problem where a build of my app, for distribution through Google Play's beta channel, was refusing to deploy to any devices. Some investigation and some help from Google revealed that the problem was this, when…
Graham Borland
  • 60,055
  • 21
  • 138
  • 179
18
votes
3 answers

What sort of equality does the Apache Commons ObjectUtils equals method test for?

I have always understood there to be two types of equality in Java, value equality : uses the .equals() method to test that two objects implement an equivalence relation on non-null object references. reference equality : uses the == operator to…
Caoilte
  • 2,381
  • 1
  • 21
  • 27
18
votes
4 answers

Is there an alternative to StringUtils.isNumeric that does what I mean?

StringUtils.isNumeric returns true for "" and false for 7.8. This is of course it's documented behavior, but really not the most convenient for me. Is there something else (ideally in commons.lang) that provides an isActuallyNumeric?
Kevin Peterson
  • 7,189
  • 5
  • 36
  • 43
17
votes
2 answers

How to create CommonsMultipartFile object given only a file

I have a junit test method that takes a CommonsMultipartFile object as a parameter. I'm trying to create a FileItem object so I can pass it to the constructor, CommonsMultipartFile(org.apache.commons.fileupload.FileItem fileItem) To do that, I'm…
wsams
  • 2,499
  • 7
  • 40
  • 51
17
votes
8 answers

Is there an equivalent to Java's ToStringBuilder for C#? What would a good C# version feature?

In the Java world we have Apache Commons' ToStringBuilder to help with creating toString() implementations. Does anyone know of a decent free implementation for C#? Are there better alternatives I don't know about? If no free implementation exists…
chillitom
  • 24,888
  • 17
  • 83
  • 118
17
votes
4 answers

duplicate classes in commons-collections and commons-beanutils

There are four duplicate classes in two Maven artifacts from Apache: commons-beanutils:commons-beanutils:1.8.3 and…
yegor256
  • 102,010
  • 123
  • 446
  • 597
16
votes
8 answers

Map that could be iterated in the order of values

I need a Map that could be iterated in the decreasing order of its values. Does any of the standard libraries like Apache Commons or Guava provide this kind of map ?
Rajat Gupta
  • 25,853
  • 63
  • 179
  • 294
16
votes
4 answers

Calculate percentile from a long array?

Given a long array of latencies which are in milliseconds, I want to calculate percentile from them. I got below method which does the work but I am not sure how I can verify whether this gives me accurate result? public static long[]…
user5447339
16
votes
5 answers

Create a folder hierarchy through FTP in Java

Is there readily available functionality for Java to create a folder hierarchy on a remote FTP server. Apache Commons does provide an FTP client, but I can't find a method for creating a directory hierarchy. It does allow for creating a single…
Pieter
  • 163
  • 1
  • 1
  • 4
16
votes
13 answers

How to compare two Collections for "equivalence" based on fields from different Java classes?

Given any two classes, e.g. ClassA and ClassB below: class ClassA { private int intA; private String strA; private boolean boolA; // Constructor public ClassA (int intA, String strA, boolean boolA) { this.intA = intA;…
Steve Chambers
  • 37,270
  • 24
  • 156
  • 208
16
votes
3 answers

Apache Commons CLI 1.3.1: How to ignore unknown Arguments?

I used to work with Apache Commons Cli 1.2. I wanted the parser to ignore arguments if they are unknown (not added to an Options-Object). Example (pseudocode): Options specialOptions; specialOptions.addOption(null, "help", false, "shows…
leif_good
  • 376
  • 6
  • 19
16
votes
2 answers

Guava Vs Apache Commons Hash/Equals builders

I was wondering what are key differences between Guava vs Apache Commons with respect to equals and hashCode builders. equals: Apache Commons: public boolean equals(Object obj) { if (obj == null) { return false; } if (obj == this) { return…
Abhishek
  • 323
  • 1
  • 3
  • 8
16
votes
4 answers

Convert java Map to custom key=value string

I have TreeMap which I need to convert to URI-like string and then back to Map. I need to set custom delimiters. Is there any tool (Guava, Apache commons?) that can do it for me? I know, I can write simple loops, but I'm looking for…
karolkpl
  • 2,189
  • 10
  • 39
  • 60