Class FileDetection


  • public class FileDetection
    extends java.lang.Object
    File detection utilities.
    • Constructor Detail

      • FileDetection

        public FileDetection()
    • 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)