Galera, é o seguinte: tenho um sistema J2EE utilizando Struts, criei uma pasta no projeto onde consta o manual do projeto. Criei um botão para fazer o download, só que sempre q coloco um link ele vai buscar no Struts - Config o PATH, tem algum codigo q faça eu fazer do download do arquivo?
String filePath = arg2.getParameter("uri");
StringBuffer buffer = new StringBuffer();
String path = null;
if (filePath != null) {
String http = ConfigConstants.getResourceBundle().getString(
"HTTP_URL");
buffer.append(http);
buffer.append(filePath);
path=buffer.toString();
}
log.finest("Path name is :" + path);
String contentType = "application/x-msexcel";
return new SI(contentType, new URL(path));
}
/**
*
@author nsuj
*/
public static class SI implements StreamInfo {
private String contentType;
private URL file;
public SI(String contentType, URL file) {
this.contentType = contentType;
this.file = file;
}
public String getContentType() {
return this.contentType;
}
/**
* Method to get a stream on the file to download
*
* @return The InputStream wrapping the file to download
*
*/
public InputStream getInputStream() throws IOException {
return file.openStream();
}