/**
* 解析文件头
* Content-Disposition:attachment;filename=FileName.txt
* Content-Disposition: attachment; filename*="UTF-8''%E6%9B%BF%E6%8D%A2%E5%AE%9E%E9%AA%8C%E6%8A%A5%E5%91%8A.pdf"
*/
private static String getHeaderFileName(Response response) {
String dispositionHeader = response.header("Content-Disposition");
if (!TextUtils.isEmpty(dispositionHeader)) {
dispositionHeader.replace("attachment;filename=", "");
dispositionHeader.replace("filename*=utf-8", "");
String[] strings = dispositionHeader.split("; ");
if (strings.length > 1) {
dispositionHeader = strings[1].replace("filename=", "");
dispositionHeader = dispositionHeader.replace("\"", "");
return dispositionHeader;
}
return "";
}
return "";
}
网友评论