Class Attachment

java.lang.Object
org.htmlunit.attachment.Attachment

public class Attachment extends Object
An attachment represents a page received from the server which contains a Content-Disposition=attachment header.
  • Constructor Details

    • Attachment

      public Attachment(Page page)
      Creates a new attachment for the specified page.
      Parameters:
      page - the attached page
    • Attachment

      public Attachment(Page page, String attachmentFilename)
      Creates a new attachment for the specified page.
      Parameters:
      page - the attached page
      attachmentFilename - the file name of this attachment
  • Method Details

    • getPage

      public Page getPage()
      Returns the attached page.
      Returns:
      the attached page
    • getSuggestedFilename

      public String getSuggestedFilename()
      Returns the attachment's filename, as suggested by the Content-Disposition header, or null if no filename was suggested.
      Returns:
      the attachment's suggested filename, or null if none was suggested
    • getSuggestedFilename

      public static String getSuggestedFilename(String contentDispositionHeader)
      Returns the attachment's filename, as suggested by the Content-Disposition header, or null if no filename was suggested.
      Parameters:
      contentDispositionHeader - the Content-Disposition header
      Returns:
      the attachment's suggested filename, or null if none was suggested