String dwPath = webAppRootString + "/telex/ground/coding/txtFile/exportFile.txt";
BufferedInputStream bis=null; 
BufferedOutputStream bos = null;
try {
bis = new BufferedInputStream(new FileInputStream(dwPath));
bos = new BufferedOutputStream(ops);//ops为jsp页面里的ServletOutputStream
byte[] buff = new byte[2048]; 
int bytesRead; 
while(-1 != (bytesRead = bis.read(buff,0,buff.length)))   { 
bos.write(buff,0,bytesRead); //将数组内容写到本地文件。
}
} catch (Exception e) {
e.printStackTrace();
}
我分析了一下原因,应该是txt里面最后有一段内容长度不够数组长度,所以就不能加到buff数组里面去,想了很久不知道有什么方法可以吧最后那段内容加到buff里面去,并且使bytesRead != -1,