Package com.vividsolutions.jump.io
Class CompressedFile
- java.lang.Object
-
- com.vividsolutions.jump.io.CompressedFile
-
public class CompressedFile extends Object
Utility class for dealing with compressed files.- Author:
- dblasby, ede
- See Also:
isCompressed(URI)
-
-
Constructor Summary
Constructors Constructor Description CompressedFile()Creates a new CompressedFile
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static StringcreateLayerName(URI uri)static String[]getArchiveExtensions()static StringgetExtension(String path)returns second level extension for compressed files eg.static String[]getFileExtensions()static StringgetInternalZipFnameByExtension(String extension, String compressedFile)Deprecated.only used by very old data readers which only deliver the first file in zip file [ede 05.2012]static StringgetTargetFileWithPath(URI uri)static booleanhasArchiveFileExtension(String filename)static booleanhasCompressedFileExtension(String filename)static booleanisArchive(String filePath)static booleanisArchive(URI uri)static booleanisBZip(String filePath)static booleanisCompressed(String filePath)static booleanisCompressed(URI uri)static booleanisGZip(String filePath)static booleanisSevenZ(String filePath)static booleanisTar(String filePath)static booleanisXZ(String filePath)static booleanisZip(String filePath)static List<URI>listEntries(File file)static InputStreamopenFile(String uri_string)static InputStreamopenFile(String filePath, String compressedEntry)Utility file open function - handles compressed and un-compressed files.static InputStreamopenFile(URI uri)static URIreplaceTargetFileName(URI uri, String filename)static URIreplaceTargetFileWithPath(URI uri, String location)
-
-
-
Method Detail
-
getInternalZipFnameByExtension
public static String getInternalZipFnameByExtension(String extension, String compressedFile) throws Exception
Deprecated.only used by very old data readers which only deliver the first file in zip file [ede 05.2012]Searches through the .zip file looking for a file with the given extension. Returns null if it doesn't find one.- Throws:
Exception
-
openFile
public static InputStream openFile(String uri_string) throws URISyntaxException, IOException
- Throws:
URISyntaxExceptionIOException
-
openFile
public static InputStream openFile(URI uri) throws IOException
- Throws:
IOException
-
openFile
public static InputStream openFile(String filePath, String compressedEntry) throws IOException
Utility file open function - handles compressed and un-compressed files.- Parameters:
filePath- name of the file to search for.compressedEntry- name of the compressed file.If compressedEntry = null, opens a FileInputStream on filePath
If filePath ends in ".zip" - opens the compressed Zip and looks for the file called compressedEntry
If filePath ends in ".gz" - opens the compressed .gz file.
- Throws:
IOException
-
isCompressed
public static boolean isCompressed(URI uri)
-
isArchive
public static boolean isArchive(URI uri)
-
isCompressed
public static boolean isCompressed(String filePath)
-
isArchive
public static boolean isArchive(String filePath)
-
isZip
public static boolean isZip(String filePath)
-
isTar
public static boolean isTar(String filePath)
-
isGZip
public static boolean isGZip(String filePath)
-
isBZip
public static boolean isBZip(String filePath)
-
isXZ
public static boolean isXZ(String filePath)
-
isSevenZ
public static boolean isSevenZ(String filePath)
-
getArchiveExtensions
public static String[] getArchiveExtensions()
-
getFileExtensions
public static String[] getFileExtensions()
-
getExtension
public static String getExtension(String path)
returns second level extension for compressed files eg. "tif" for "file.tif.gz" all others the first extension eg. "tif" for "file.tif"- Parameters:
path- a file path- Returns:
- the extension for this file
-
hasCompressedFileExtension
public static boolean hasCompressedFileExtension(String filename)
-
hasArchiveFileExtension
public static boolean hasArchiveFileExtension(String filename)
-
-