/** * 获取response header中Content-Disposition中的filename值 * @param response * @return */ private static String getFileName(HttpResponse response) { Header contentHeader = response.getFirstHeader("Content-Disposition"); String filename = null; if (contentHeader != null) { HeaderElement[] values = contentHeader.getElements(); if (values.length == 1) { NameValuePair param = values[0].getParameterByName("filename"); if (param != null) { try { //此处根据具体编码来设置 filename = new String(param.getValue().toString().getBytes("ISO-8859-1"), "GBK"); } catch (Exception e) { e.printStackTrace(); } } } } return filename; }