http文件传输

上传端:
File uploadFile =new File();
PostMethod mPost = null;
try{
    String targetURL =";
    HttpClient client = new HttpClient();
    mPost = new PostMethod(targetURL);
    Part [] part = {new FilePart(uploadFile.getName(), uploadFile)};
    mPost.setRequestEntity(new MultipartRequestEntity(part,mPost.getParams()));
    mPost.setRequestHeader("cookies", "");
    client.executeMethod(mPost);
    if(mPost.getStatusCode()==200){ } 
}

接受端:

使用

DiskFileItemFactory factory = new DiskFileItemFactory();

posted on 2017-05-23 14:59  loveflying  阅读(227)  评论(0编辑  收藏  举报