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
35
votes
8 answers

Does Apache Commons HttpClient support GZIP?

Does the library Apache Commons HttpClient support Gzip? We wanted to use enable gzip compression on our Apache server to speed up the client/server communications (we have a php page that allows our Android application to sync files with the…
35
votes
6 answers

Most efficient way to find the collection of all ids in a collection of entities

I have an entity: public class Entity { private long id; private String data; public long getId() { return id; } public String getData() { return data; } } and a collection of…
rapt
  • 11,810
  • 35
  • 103
  • 145
34
votes
6 answers

HashCodeBuilder and EqualsBuilder usage style

I often use apache HashCodeBuilder and EqualsBuilder for object equality using reflection, but recently I a colleague told me that using reflection may cause a huge performance hit if the entity contains lots of properties. Worried that I may be…
tintin
  • 5,676
  • 15
  • 68
  • 97
33
votes
6 answers

Lightweight JDBC helper library alternative to Apache Commons DbUtils

I've just developed my own tiny little JDBC helper library, and I've already realized what a maintenance nightmare it will be. I'm not looking for a full fledged ORM, like Hibernate, just something light and useful to quickly make JDBC calls passing…
opensas
  • 60,462
  • 79
  • 252
  • 386
33
votes
7 answers

Append data into a file using Apache Commons I/O

The FileUtils.writeStringToFile(fileName, text) function of Apache Commons I/O overwrites previous text in a file. I would like to append data to my file. Is there any way I could use Commons I/O for the same? I can do it using normal BufferedWriter…
Dexter
  • 11,311
  • 11
  • 45
  • 61
33
votes
2 answers

Is there any generic version of toArray() in Guava or Apache Commons Collections?

What I'm looking for is a generic version of Object[] java.util.Collection.toArray() or a less verbose alternative to using T[] java.util.Collection.toArray(T[] array). I can currently write: Collection strings; String[] array =…
Mihai
  • 1,261
  • 2
  • 12
  • 19
31
votes
3 answers

What is the use case for null(Input/Output)Stream API in Java?

With Java 11, I could initialize an InputStream as: InputStream inputStream = InputStream.nullInputStream(); But I am unable to understand a potential use case of InputStream.nullInputStream or a similar API for OutputStream i.e.…
Naman
  • 27,789
  • 26
  • 218
  • 353
30
votes
4 answers

IMAP client in Java: JavaMail API or Apache Commons Net?

I have to implement an IMAP Client in Java. Which advantages has using the Apache Commons Net library? Does it make the implementation robust and more flexible? How do I have to handle return values, it always produces strings. For example: public…
benchpresser
  • 2,171
  • 2
  • 23
  • 41
30
votes
2 answers

Commons CLI required groups

I am writing command line application in Java and I've chosen Apache Commons CLI to parse input arguments. Let's say I have two required options (ie. -input and -output). I create new Option object and set required flag. For now it's all good. But I…
29
votes
4 answers

Process output from apache-commons exec

I am at my wits end here. I'm sure this is something simple and I most likely have huge holes in my understanding of java and streams. I think there are so many classes that I'm a bit overwhelmed with trying to poke through the API to figure out…
James DeRagon
  • 364
  • 1
  • 4
  • 11
29
votes
1 answer

Is there any difference between Apache's Base64.encodeBase64 and Android's Base64.encode with Base64.Default flag?

Sample A (using org.apache.commons.codec.binary.Base64): Base64.encodeBase64("foobar".getBytes()); Sample B (using android.util.Base64): Base64.encode("foobar".getBytes(), Base64.DEFAULT); Do these produce the same string?
Alex Florescu
  • 5,096
  • 1
  • 28
  • 49
26
votes
2 answers

How to fetch parameters when using the Apache Commons CLI library

I'm using the Apache Commons CLI to handle command line arguments in Java. I've declared the a and b options and I'm able to access the value using CommandLine.getOptionValue(). Usage: myapp [OPTION] [DIRECTORY] Options: -a Option A -b …
Mridang Agarwalla
  • 43,201
  • 71
  • 221
  • 382
25
votes
5 answers

Secure FTP with org.apache.commons.net.ftp.FTPClient

Is there a way I can implement a secure FTP with org.apache.commons.net.ftp.FTPClient? If not, what are other options for Java?
user1725253
  • 329
  • 1
  • 4
  • 13
24
votes
3 answers

Is there an enum with MIME Types in Java?

Possible Duplicate: Interface/enum listing standard mime-type constants Is there an enum (or something similar) which holds constants for the most common MIME types? I'd like to deal with some constants rather than firing Strings here and there.
Fabian Barney
  • 14,219
  • 5
  • 40
  • 60
24
votes
2 answers

Why are detected CLI options different when using DefaultParser instead of GnuParser?

I'm about to migrate some legacy code to contain less deprecated warnings from 3rd-party libraries. For Apache commons-cli library (version: 1.3.1) I detected in the official JavaDoc that GnuParser is deprecated and DefaultParser should be used…
MWiesner
  • 8,868
  • 11
  • 36
  • 70