Top Description Fields Constructors Methods
org.apache.commons.compress.compressors.gzip

public Class GzipUtils

extends Object
Class Inheritance
Imports
java.nio.charset.Charset, .StandardCharsets, java.util.LinkedHashMap, .Map, org.apache.commons.compress.compressors.FileNameUtil

Utility code for the gzip compression format.

Field Summary

Modifier and TypeField and Description
private static final FileNameUtil
pack-priv static final Charset
GZIP_ENCODING

Encoding for file name and comments per the GZIP File Format Specification

Constructor Summary

AccessConstructor and Description
private
GzipUtils()

Private constructor to prevent instantiation of this utility class.

Method Summary

Modifier and TypeMethod and Description
public static String

Returns:

name of the corresponding compressed file
getCompressedFilename
(final String
name of a file
fileName
)

Maps the given file name to the name that the file should have after compression with gzip.
public static String

Returns:

name of the corresponding compressed file
getCompressedFileName
(final String
name of a file
fileName
)

Maps the given file name to the name that the file should have after compression with gzip.

public static String

Returns:

name of the corresponding uncompressed file
getUncompressedFilename
(final String
name of a file
fileName
)

Maps the given name of a gzip-compressed file to the name that the file should have after uncompression.
public static String

Returns:

name of the corresponding uncompressed file
getUncompressedFileName
(final String
name of a file
fileName
)

Maps the given name of a gzip-compressed file to the name that the file should have after uncompression.

public static boolean

Returns:

true if the file name has a common gzip suffix, false otherwise
isCompressedFilename
(final String
name of a file
fileName
)

Detects common gzip suffixes in the given file name.
public static boolean

Returns:

true if the file name has a common gzip suffix, false otherwise
isCompressedFileName
(final String
name of a file
fileName
)

Detects common gzip suffixes in the given file name.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

fileNameUtilback to summary
private static final FileNameUtil fileNameUtil
GZIP_ENCODINGback to summary
pack-priv static final Charset GZIP_ENCODING

Encoding for file name and comments per the GZIP File Format Specification

Constructor Detail

GzipUtilsback to summary
private GzipUtils()

Private constructor to prevent instantiation of this utility class.

Method Detail

getCompressedFilenameback to summary
public static String getCompressedFilename(final String fileName)

Maps the given file name to the name that the file should have after compression with gzip. Common file types with custom suffixes for compressed versions are automatically detected and correctly mapped. For example the name "package.tar" is mapped to "package.tgz". If no custom mapping is applicable, then the default ".gz" suffix is appended to the file name.

Parameters
fileName:String

name of a file

Returns:String

name of the corresponding compressed file

Annotations
@Deprecated
getCompressedFileNameback to summary
public static String getCompressedFileName(final String fileName)

Maps the given file name to the name that the file should have after compression with gzip. Common file types with custom suffixes for compressed versions are automatically detected and correctly mapped. For example the name "package.tar" is mapped to "package.tgz". If no custom mapping is applicable, then the default ".gz" suffix is appended to the file name.

Parameters
fileName:String

name of a file

Returns:String

name of the corresponding compressed file

Since
1.25.0
getUncompressedFilenameback to summary
public static String getUncompressedFilename(final String fileName)

Maps the given name of a gzip-compressed file to the name that the file should have after uncompression. Commonly used file type specific suffixes like ".tgz" or ".svgz" are automatically detected and correctly mapped. For example the name "package.tgz" is mapped to "package.tar". And any file names with the generic ".gz" suffix (or any other generic gzip suffix) is mapped to a name without that suffix. If no gzip suffix is detected, then the file name is returned unmapped.

Parameters
fileName:String

name of a file

Returns:String

name of the corresponding uncompressed file

Annotations
@Deprecated
getUncompressedFileNameback to summary
public static String getUncompressedFileName(final String fileName)

Maps the given name of a gzip-compressed file to the name that the file should have after uncompression. Commonly used file type specific suffixes like ".tgz" or ".svgz" are automatically detected and correctly mapped. For example the name "package.tgz" is mapped to "package.tar". And any file names with the generic ".gz" suffix (or any other generic gzip suffix) is mapped to a name without that suffix. If no gzip suffix is detected, then the file name is returned unmapped.

Parameters
fileName:String

name of a file

Returns:String

name of the corresponding uncompressed file

Since
1.25.0
isCompressedFilenameback to summary
public static boolean isCompressedFilename(final String fileName)

Detects common gzip suffixes in the given file name.

Parameters
fileName:String

name of a file

Returns:boolean

true if the file name has a common gzip suffix, false otherwise

Annotations
@Deprecated
isCompressedFileNameback to summary
public static boolean isCompressedFileName(final String fileName)

Detects common gzip suffixes in the given file name.

Parameters
fileName:String

name of a file

Returns:boolean

true if the file name has a common gzip suffix, false otherwise

Since
1.25.0