Java tutorial
//package com.java2s; import java.io.UnsupportedEncodingException; public class Main { private static byte[] getFileParameters(String fileName, String contentType, String charset) throws UnsupportedEncodingException { StringBuilder sb = new StringBuilder(); sb.append("Content-Disposition:form-data;name=\""); sb.append("upload"); sb.append("\";filename=\""); sb.append(fileName); sb.append("\"\r\nContent-Type:"); sb.append(contentType); sb.append("\r\n\r\n"); return sb.toString().getBytes(charset); } }