Package org.c02e.jpgpj.util
Class FileDetection
java.lang.Object
org.c02e.jpgpj.util.FileDetection
File detection utilities.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
static class
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondetectContainer
(InputStream stream) Scans the first few bytes of the specified input stream, and tries to determine if it's a known PGP container format.detectContainer
(InputStream stream, int bufferSize) Scans the first few bytes of the specified input stream, and tries to determine if it's a known PGP container format.protected static boolean
isAllArmor
(byte[] buf) protected static boolean
isArmorByte
(byte b)
-
Field Details
-
SCAN_AHEAD
protected static final int SCAN_AHEAD- See Also:
-
-
Constructor Details
-
FileDetection
public FileDetection()
-
-
Method Details
-
detectContainer
Scans the first few bytes of the specified input stream, and tries to determine if it's a known PGP container format. Since this function reads the first few bytes from the passed input stream, it will pass back a reference to another input stream as part of the detection result. Use the returned stream to read from the start of the original stream. (If the original input stream supports marking and reseting, it will be reset and passed back; otherwise it will be wrapped with a new buffered input stream, and the wrapper stream will be passed back.)- Parameters:
stream
- Input stream to check.- Returns:
- Detection result, including likely container type, and the wrapper input stream.
- Throws:
IOException
-
detectContainer
public static FileDetection.DetectionResult detectContainer(InputStream stream, int bufferSize) throws IOException Scans the first few bytes of the specified input stream, and tries to determine if it's a known PGP container format. Since this function reads the first few bytes from the passed input stream, it will pass back a reference to another input stream as part of the detection result. Use the returned stream to read from the start of the original stream. (If the original input stream supports marking and reseting, it will be reset and passed back; otherwise it will be wrapped with a new buffered input stream, and the wrapper stream will be passed back.)- Parameters:
stream
- Input stream to check.bufferSize
- Size of buffer to create if the input stream does not support marking and resetting.- Returns:
- Detection result, including likely container type, and the wrapper input stream.
- Throws:
IOException
-
isAllArmor
protected static boolean isAllArmor(byte[] buf) -
isArmorByte
protected static boolean isArmorByte(byte b)
-