Package org.c02e.jpgpj.util
Class FileDetection
- java.lang.Object
-
- org.c02e.jpgpj.util.FileDetection
-
public class FileDetection extends java.lang.Object
File detection utilities.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
FileDetection.ContainerType
static class
FileDetection.DetectionResult
-
Field Summary
Fields Modifier and Type Field Description protected static int
SCAN_AHEAD
-
Constructor Summary
Constructors Constructor Description FileDetection()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static FileDetection.DetectionResult
detectContainer(java.io.InputStream stream)
Scans the first few bytes of the specified input stream, and tries to determine if it's a known PGP container format.static FileDetection.DetectionResult
detectContainer(java.io.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 Detail
-
SCAN_AHEAD
protected static final int SCAN_AHEAD
- See Also:
- Constant Field Values
-
-
Method Detail
-
detectContainer
public static FileDetection.DetectionResult detectContainer(java.io.InputStream stream) throws java.io.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.- Returns:
- Detection result, including likely container type, and the wrapper input stream.
- Throws:
java.io.IOException
-
detectContainer
public static FileDetection.DetectionResult detectContainer(java.io.InputStream stream, int bufferSize) throws java.io.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:
java.io.IOException
-
isAllArmor
protected static boolean isAllArmor(byte[] buf)
-
isArmorByte
protected static boolean isArmorByte(byte b)
-
-