Package nom.tam.fits.compress
Class CompressionManager
java.lang.Object
nom.tam.fits.compress.CompressionManager
(for internal use) Decompression of compressed FITS files of all supported types (
.gz,
.Z, .bz2). It autodetects the type of compression used based on the first 2-bytes of the
compressed input stream. When possible, preference will be given to perform the decompression using a system command
(uncompress or bzip2, which are likely faster for large files). If such a tool is not
available, then the Apache common-compress classes will be used to the same effect.-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic InputStreamdecompress(InputStream compressed) This method decompresses a compressed input stream.static booleanisCompressed(File file) Is a file compressed? (the magic number in the first 2 bytes is used to detect the compression.static booleanisCompressed(String filename) Checks if a file is compressed.protected static ICompressProvidernextCompressionProvider(int mag1, int mag2, ICompressProvider old) Returned the next highest priority decompression class, after the one we don't want, for the given type of compressed file.
-
Field Details
-
ONE_MEGABYTE
public static final int ONE_MEGABYTEbytes in a megabyte (MB)- See Also:
-
-
Method Details
-
decompress
This method decompresses a compressed input stream. The decompression method is selected automatically based upon the first two bytes read.- Parameters:
compressed- The compressed input stream- Returns:
- A stream which wraps the input stream and decompresses it. If the input stream is not compressed, a pushback input stream wrapping the original stream is returned.
- Throws:
FitsException- when the stream could not be read or decompressed
-
isCompressed
Is a file compressed? (the magic number in the first 2 bytes is used to detect the compression.- Parameters:
file- file to test for compression algorithms- Returns:
- true if the file is compressed
-
isCompressed
Checks if a file is compressed. If the file by the name exists, it will check the magic number in the first 2-bytes to see if they matched those of the supported compression algorithms. Otherwise it checks if the file extension atches one of the standard extensions for supported compressed files (
.gz,.Z, or.bz2).As of 1.18, all file extension are checked in a case insensitive manner
- Parameters:
filename- of the file to test for compression algorithms- Returns:
- true if the file is compressed
-
nextCompressionProvider
protected static ICompressProvider nextCompressionProvider(int mag1, int mag2, ICompressProvider old) Returned the next highest priority decompression class, after the one we don't want, for the given type of compressed file.- Parameters:
mag1- the first magic byte at the head of the compressed filemag2- the second magic byte at the head of the compressed fileold- the last decompression class we tried for this type of file- Returns:
- the next lower priority decompression class we might use.
-