将文件 post 到一个上传地址上存储:
public static void main(String[] args) { HttpClient client = new DefaultHttpClient(); HttpPost httpPost = new HttpPost("http://uploadurl");// 上传地址 FileBody fileBody = new FileBody(new File("d:\\test.mp4"));// 文件位置 StringBody stringBody; try { MultipartEntity entity = new MultipartEntity(); entity.addPart("file", fileBody); httpPost.setEntity(entity); HttpResponse response = client.execute(httpPost); if(response.getStatusLine().getStatusCode() == HttpStatus.SC_OK){ // 上传成功 } } catch (Exception e) { e.printStackTrace(); } }