做项目进程中,须要依据他人供给的URL去下载附件。
// 树立衔接 HttpClient client = new HttpClient(); client.getHttpConnectionManager().getParams().setConnectionTimeout(5000); HttpMethod method = null; // 取得文件流 method = new GetMethod(url); client.executeMethod(method); // 打印http交互信息 printHttpInteractInfo(method); // 获得文件流 InputStream inputStream = method.getResponseBodyAsStream(); // 树立衔接 HttpClien