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
676
votes
31 answers

How can I convert byte size into a human-readable format in Java?

How can I convert byte size into a human-readable format in Java? Like 1024 should become "1 Kb" and 1024*1024 should become "1 Mb". I am kind of sick of writing this utility method for each project. Is there a static method in Apache Commons for…
Igor Mukhin
  • 15,014
  • 18
  • 52
  • 61
246
votes
19 answers

What is the best Java email address validation method?

What are the good email address validation libraries for Java? Are there any alternatives to commons validator?
jon077
  • 10,303
  • 11
  • 39
  • 37
219
votes
5 answers

Google Guava vs. Apache Commons

I was looking for a bidirectional map implementation in Java, and stumbled upon these two libraries: Google Guava (formerly "Google Collections") Apache Commons Collections Both are free, have the bidirectional map implementation that I was…
Joonas Pulakka
  • 36,252
  • 29
  • 106
  • 169
192
votes
13 answers

How can I get an HTTP response body as a string?

I know there used to be a way to get it with Apache Commons as documented here: http://hc.apache.org/httpclient-legacy/apidocs/org/apache/commons/httpclient/HttpMethod.html ...and an example here: http://www.kodejava.org/examples/416.html ...but I…
Daniel Shaulov
  • 2,354
  • 2
  • 16
  • 25
179
votes
9 answers

How can I generate a list or array of sequential integers in Java?

Is there a short and sweet way to generate a List, or perhaps an Integer[] or int[], with sequential values from some start value to an end value? That is, something shorter than, but equivalent to1 the following: void List
BeeOnRope
  • 60,350
  • 16
  • 207
  • 386
177
votes
10 answers

Http Basic Authentication in Java using HttpClient?

I am trying to mimic the functionality of this curl command in Java: curl --basic --user username:password -d "" http://ipaddress/test/login I wrote the following using Commons HttpClient 3.0 but somehow ended up getting an 500 Internal Server…
Legend
  • 113,822
  • 119
  • 272
  • 400
161
votes
8 answers

Apache Commons equals/hashCode builder

I'm curious to know, what people here think about using org.apache.commons.lang.builder EqualsBuilder/HashCodeBuilder for implementing the equals/hashCode? Would it be a better practice than writing your own? Does it play well with Hibernate?…
aug70co
  • 3,965
  • 5
  • 30
  • 44
126
votes
3 answers

What are the big improvements between guava and apache equivalent libraries?

We currently use apache collections, string utils, etc. I need to decide if we should switch from the apache foundations implementation. The important criteria is ease of developers use. Performance/memory usage is not yet an important issue for us.…
Pat
  • 5,761
  • 5
  • 34
  • 50
119
votes
6 answers

Bi-directional Map in Java?

I have a simple integer-to-string mapping in Java, but I need to be able to easily retrieve string from integer, and also integer from string. I've tried Map, but it can retrieve only string from integer, it's one way: private static final…
Danijel
  • 8,198
  • 18
  • 69
  • 133
112
votes
12 answers

Is StringUtils.EMPTY recommended?

Do you use StringUtils.EMPTY instead of ""? I mean either as a return value or if you set a the value of a String variable. I don't mean for comparison, because there we use StringUtils.isEmpty()
keuleJ
  • 3,418
  • 4
  • 30
  • 51
110
votes
3 answers

Logging framework incompatibility

I'm building a small Java app and hoping to use logback for logging. My app has a dependency on an older project that does its logging via org.apache.commons | com.springsource.org.apache.commons.logging | 1.1.1 ...so my plan was to use org.slf4j…
Carl Smotricz
  • 66,391
  • 18
  • 125
  • 167
87
votes
7 answers

How to send java.util.logging to log4j?

I have an existing application which does all of its logging against log4j. We use a number of other libraries that either also use log4j, or log against Commons Logging, which ends up using log4j under the covers in our environment. One of our…
matt b
  • 138,234
  • 66
  • 282
  • 345
87
votes
3 answers

How to Serialize a list in java?

I would like to deep clone a List. for that we are having a method // apache commons method. This object should be serializable SerializationUtils.clone ( object ) so now to clone my List i should convert that to serializable first. Is it possible…
Rakesh Juyal
  • 35,919
  • 68
  • 173
  • 214
74
votes
4 answers

Range of valid character for a base 64 encoding

I am interested in the following: Is there a list of characters that would never occur as part of a base 64 encoded string? For example *. I am not sure if this would occur or not. If the original input actually had * as part of it would that be…
Jim
  • 18,826
  • 34
  • 135
  • 254
72
votes
6 answers

tomcat-dbcp vs commons-dbcp

It seems there is a lot of confusion between these two connection pooling libraries. What I want to know is which one is better (if at all)? Here are some points which I would like to put up... Could someone please verify? Tomcat DBCP: uses the…
rabbit
  • 721
  • 1
  • 6
  • 3
1
2 3
99 100