0

I would like to use commons-compress to work with various compression/archive formats.

However on first look it seems commons-compress only supports detecting some types of files, but only based on the first few bytes.

Is there a way I can use commons-compress to automatically detect file-types based on file extension? I surely can build this myself, but it would be nice to have this provided by the compression library itself.

centic
  • 15,565
  • 9
  • 68
  • 125

1 Answers1

0

After some more digging, I found that there are a few classes that help here, namely FilenameUtil, BZip2Utils, GzipUtils, ... so for each supported format, there is a *Utils class which allows to detect this type by extension.

See e.g. http://commons.apache.org/proper/commons-compress/javadocs/api-1.10/org/apache/commons/compress/compressors/bzip2/BZip2Utils.html

centic
  • 15,565
  • 9
  • 68
  • 125