Class Sniffer

java.lang.Object
org.faceless.publisher.type.Sniffer

public class Sniffer extends Object
The Sniffer is used to determine the Media-Type of a URL based on its content if possible, or the filename in the URL if not
  • Method Details

    • sniff

      public static MediaType sniff(Path path) throws IOException
      Given a file at the specified path, sniff the file-type
      Parameters:
      path - the path
      Returns:
      the guessed MediaType or null if it's not recognised
      Throws:
      IOException
    • sniff

      public static MediaType sniff(InputStream in, URL2 uri) throws IOException
      Given a mark-capable InputStream, attempt to guess the MediaType. The stream is reset to its initial position at the end of this method.
      Parameters:
      in - the InputStream, which must have InputStream.markSupported() return true
      Returns:
      the guessed MediaType or null if it's not recognised
      Throws:
      IOException