Class FileDetection

java.lang.Object
org.c02e.jpgpj.util.FileDetection

public class FileDetection extends Object
File detection utilities.
  • Field Details

  • Constructor Details

    • FileDetection

      public FileDetection()
  • Method Details

    • detectContainer

      public static FileDetection.DetectionResult detectContainer(InputStream stream) 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.
      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)