Class Part

java.lang.Object
au.id.villar.web.mfd.Part

public class Part extends Object
Object representing a part detected when parsing an HTTP multipart request body.
  • Method Details

    • getHeaderValue

      public String getHeaderValue(String headerName)
      Retrieves the first value found for a header.
      Parameters:
      headerName - the name of the header whose value is requested.
      Returns:
      The first value found for the given header.
    • getHeaderValues

      public List<String> getHeaderValues(String headerName)
      Retrieves all the values found for a given header.
      Parameters:
      headerName - the name of the header whose values are requested.
      Returns:
      A list containing all values found for the given header.
    • getHeaderNames

      public Set<String> getHeaderNames()
      Retrieves all headers found when parsing the part represented by this object.
      Returns:
      A List containing all headers found when parsing the part represented by this object.
    • getName

      public String getName()
      Returns the field "name" from the Content-Disposition header.
      Returns:
      The value of the field "name" from the Content-Disposition header, or null if it wasn't found.
    • getFilename

      public String getFilename()
      Returns the field "filename" from the Content-Disposition header.
      Returns:
      The value of the field "filename" from the Content-Disposition header, or null otherwise.
    • getBodyStream

      public InputStream getBodyStream()
      Returns the stream representing this part's body. This InputStream is not reset every time this method is called, it rather returns the same instance every time. This instance may return EOF (-1) if it has been already consumed by one of the convenience methods readBodyText() or readBodyText(Charset).
      Returns:
      the InputStream representing this part's body.
    • readBodyText

      public String readBodyText() throws IOException
      Convenience method to read this part's body into a single String.
      Returns:
      A String containing this part's body.
      Throws:
      IOException - If the underlying InputStream throws this exception.
    • readBodyText

      public String readBodyText(Charset charset) throws IOException
      Convenience method to read this part's body into a single String.
      Parameters:
      charset - The Charset used to parse this Part's body into a String
      Returns:
      A String containing this part's body.
      Throws:
      IOException - If the underlying InputStream throws this exception.