文件上传的代码
这是文件上传的代码:
package cn.ccut.edu.down;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import org.apache.struts2.ServletActionContext;
import com.opensymphony.xwork2.ActionSupport;
public class DownLoad extends ActionSupport
{
/**
*
*/
private static final long serialVersionUID = -53522970741035460L;
private static final String DOWNLOADFILEPATH=ServletActionContext.getServletContext().getRealPath("\\upload");
private String fileName;
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public InputStream getDownloadFile(InputStream downloadFile)
{
return ServletActionContext.getServletContext().getResourceAsStream(DOWNLOADFILEPATH+fileName);
}
public String getDownloadChineseFileName()
{
String downloadChineseFileName=fileName;
try
{
downloadChineseFileName=new String(downloadChineseFileName.getBytes(),"ISO-8859-1");
}
catch(UnsupportedEncodingException e)
{
e.printStackTrace();
}
return downloadChineseFileName;
}
public String execute()
{
return SUCCESS;
}
}