- java.lang.Object
-
- com.ibm.dtfj.utils.file.FileSniffer
-
public class FileSniffer extends Object
Sniffs files attempting to determine the contents, typically from known magic numbers/values.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
FileSniffer.CoreFormatType
-
Constructor Summary
Constructors Constructor Description FileSniffer()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static FileSniffer.CoreFormatType
getCoreFormat(ImageInputStream iis)
Determine the format of the core file.static boolean
isCoreFile(InputStream in, long filesize)
static boolean
isCoreFile(ImageInputStream iis, long filesize)
static boolean
isJavaCoreFile(InputStream in, long filesize)
static boolean
isJavaCoreFile(ImageInputStream iis, long filesize)
static boolean
isPHDFile(InputStream in, long filesize)
static boolean
isPHDFile(ImageInputStream iis, long filesize)
static boolean
isZipFile(File file)
static boolean
isZipFile(ImageInputStream iis)
Checks to see if the input stream is for a zip file, assumes that the stream is correctly positioned.
-
-
-
Method Detail
-
getCoreFormat
public static FileSniffer.CoreFormatType getCoreFormat(ImageInputStream iis) throws IOException
Determine the format of the core file.- Parameters:
iis
- stream to the core file- Returns:
- format
- Throws:
IOException
- re-thrown
-
isCoreFile
public static boolean isCoreFile(InputStream in, long filesize) throws IOException
- Throws:
IOException
-
isCoreFile
public static boolean isCoreFile(ImageInputStream iis, long filesize) throws IOException
- Throws:
IOException
-
isJavaCoreFile
public static boolean isJavaCoreFile(InputStream in, long filesize) throws IOException
- Throws:
IOException
-
isJavaCoreFile
public static boolean isJavaCoreFile(ImageInputStream iis, long filesize) throws IOException
- Throws:
IOException
-
isPHDFile
public static boolean isPHDFile(InputStream in, long filesize) throws IOException
- Throws:
IOException
-
isPHDFile
public static boolean isPHDFile(ImageInputStream iis, long filesize) throws IOException
- Throws:
IOException
-
isZipFile
public static boolean isZipFile(ImageInputStream iis) throws IOException
Checks to see if the input stream is for a zip file, assumes that the stream is correctly positioned. This method will reset the stream if possible to it's starting position. The reason for using this method over just trying java.util.zip.ZipFile(File) and catching errors is that on some platforms the zip support is provided by native libraries. It is possible to cause the native library to crash when speculatively passing files into it.- Parameters:
in
- stream to analyze- Returns:
- true if it is a zip file
- Throws:
IOException
-
isZipFile
public static boolean isZipFile(File file) throws IOException
- Throws:
IOException
-
-