打开文件
来源:互联网 发布:js 处理 display none 编辑:程序博客网 时间:2024/04/29 22:09
public ActionForward openFile(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
System.err.println("===com.eastpro.batch.action.BankBillingAction.openFile===begin===");
String fileName=request.getParameter("fileName");
String filePath="";
try{
response.setContentType("text/plain; charset=UTF-8");
response.setHeader("Cache-Control", "no-cache");
response.setHeader("Charset", "UTF-8");
Function ff = new Function();
Collection sys_result = ff.getSysParam();
Data sys_data = (Data) sys_result.iterator().next();
String exportPath = sys_data.getVcharProperty("export_path").trim();
sys_data = null;
sys_result = null;
ff = null;
filePath=exportPath+fileName;
OutputStream out=response.getOutputStream();
File file=new File(filePath);
InputStream is = new FileInputStream(file);
byte temp[] = new byte[100 * 1024];
int i=0;
while((i=is.read(temp))!=-1){
out.write(temp, 0, i);
}
out.flush();
out.close();
out=null;
}catch (Exception e){
System.err.println("Error: com.eastpro.batch.action.BankBillingAction.openFile()");
e.printStackTrace();
}
System.err.println("===com.eastpro.batch.action.BankBillingAction.openFile===end===");
return null;
}
public ActionForward openFileOri(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
System.err.println("===com.eastpro.batch.action.BankBillingAction.openFile===begin===");
String fileName=request.getParameter("fileName");
String filePath="";
try{
response.setContentType("text/plain; charset=UTF-8");
response.setHeader("Cache-Control", "no-cache");
response.setHeader("Charset", "UTF-8");
Function ff = new Function();
Collection sys_result = ff.getSysParam();
Data sys_data = (Data) sys_result.iterator().next();
String exportPath = sys_data.getVcharProperty("export_path").trim();
sys_data = null;
sys_result = null;
ff = null;
filePath=exportPath+fileName;
OutputStream out=response.getOutputStream();
File file=new File(filePath);
BufferedReader in=new BufferedReader(new FileReader(file));
String strLine="";
byte temp[] = new byte[100 * 1024];
while((strLine=in.readLine())!=null){
temp=strLine.getBytes();
out.write(temp, 0, temp.length);
}
out.flush();
out.close();
out=null;
}catch (Exception e){
System.err.println("Error: com.eastpro.batch.action.BankBillingAction.openFile()");
e.printStackTrace();
}
System.err.println("===com.eastpro.batch.action.BankBillingAction.openFile===end===");
return null;
}
- 打开路径打开文件
- 打开文件
- 打开文件
- 打开文件
- 文件打开
- 打开文件
- 打开文件
- ~~~打开文件~~~
- 打开文件
- 打开文件
- 文件打开
- 文件流 打开文件
- 打开文件 读写文件
- Android 文件打开文件
- 打开文件夹与打开文件
- c# 打开文件夹 、打开文件
- C# 指定打开文件方式打开文件
- 打开外部文件-如打开pdf文件
- (转)servlet/jsp中得到表单数据的3种方法request.getParameter()、request.getInputStream()和request.getReader()
- CX_SY_CONVERSION_NO_DATE_TIME
- UBUNTU基本配置
- PHP 通过curl库函数获取网页内容
- Java 7已经完成的七大新功能预览
- 打开文件
- CASE when then
- 线性表,链表,哈希表是常用的数据结构,在进行Java开发时
- PHP获取客户端、服务器信息
- 两个系统
- 海康威视(HIKViSION)2009年校园招聘笔试题-杭州(2)
- flash player在 unbuntu linux 下,百度MP3音乐盒歌词显示乱码
- Roewe theme for blackberry 9000 OS 5.0
- 2009-11-26