日期:2014-05-17  浏览次数:20709 次

debug模式没问题,正常启动就报文件找不到?
项目路径,目的是读取到uploadfiles中的文件
代码:
		for(String str:allFiles){
String[] ary=str.split(":");
File f=new File(ary[0]);//ary[0]:uploadfiels/text.txt
FileInputStream fis=new FileInputStream(f);//此处debug模式没问题,正常启动报错,文件找不到,路径错误
zos.putNextEntry(new ZipEntry(ary[1]));
int j=0;
byte[]  buffer=new byte[1024];
while((j=fis.read(buffer))>0){
zos.write(buffer,0,j);
}
fis.close();
}

求大神指点一二,debug模式和正常启动难道有什么区别么?

------解决方案--------------------
ary[0]:uploadfiels/text.txt
错了吧?
ary[0]:uploadfiles/text.txt
------解决方案--------------------
ServletActionContext.getRequest().getSession().getServletContext().getRealPath