Struts2写下载功能时,网上找了获取输出文件的名称的方法,有点不明白

/**
* 获取输出文件的名。
*
* @return 保存名
*/
public String getOutName() {

    try {
        int index = outName.lastIndexOf(".");
        String outType = outName.substring(index);
        String newOutName = outName.substring(0, index - 1);
        // newOutName=newOutName.substring(0,
        // newOutName.length()-12)+outType;
        newOutName = URLDecoder.decode(ServletActionContext.getRequest()
                .getParameter("downName"))
                + outType;
        this.outName = new String(newOutName.getBytes(), "UTF-8");
    } catch (UnsupportedEncodingException e) {
        try {
            throw new ProgramException("文件名编码异常!", e);
        } catch (ProgramException se) {
            log.error(se.getMessage(), se);
        }
    }
    return outName;
}

[code="java"]
// 获取最后一个点号
int index = outName.lastIndexOf(".");
// 获取扩展名
String outType = outName.substring(index);
// 获取文件名,不包含扩展名
String newOutName = outName.substring(0, index - 1);
// newOutName=newOutName.substring(0,
// newOutName.length()-12)+outType;
// 把Request里传过来的名字和扩展名拼到了一起
newOutName = URLDecoder.decode(ServletActionContext.getRequest()
.getParameter("downName"))

  • outType; // 生成文件名 this.outName = new String(newOutName.getBytes(), "UTF-8"); [/code]