Java Content Type Get getContentType(String boundary)

Here you can find the source of getContentType(String boundary)

Description

Gets the content type string suitable for the java.net.URLConnection which includes the multipart boundary string.

License

Open Source License

Parameter

Parameter Description
boundary the boundary string

Return

the content type string

Declaration

public static String getContentType(String boundary) 

Method Source Code

//package com.java2s;

public class Main {
    /**/*from   w  w  w.j  ava 2  s  . c  o  m*/
     * Gets the content type string suitable for the 
     * <code>java.net.URLConnection</code> which includes the multipart 
     * boundary string.  <br />
     * <br />
     * This method is static because, due to the nature of the 
     * <code>java.net.URLConnection</code> class, once the output stream 
     * for the connection is acquired, it's too late to set the content 
     * type (or any other request parameter).  So one has to create a 
     * multipart boundary string first before using this class, such as 
     * with the <code>createBoundary()</code> method.  
     * 
     * @param  boundary  the boundary string
     * @return  the content type string
     * @see  #createBoundary()
     */
    public static String getContentType(String boundary) {
        return "multipart/form-data; boundary=" + boundary;
    }
}

Related

  1. getContentType(File file)
  2. getContentType(File file)
  3. getContentType(final File file)
  4. getContentType(final String filename)
  5. getContentType(String file)
  6. getContentType(String fileName)
  7. getContentType(String filename)
  8. getContentType(String name)