关键代码如下:
FileInputStream fis = new FileInputStream(localfile);
InputStreamReader isr = new InputStreamReader(fis);
BufferedReader br = new BufferedReader(isr);
ServletOutputStream sos = response.getOutputStream();
String line;
try{
while ((line = br.readLine()) != null){
line += "\n ";
System.out.print( "line is : "+line);
sos.write(line.getBytes());
}
} catch (java.io.EOFException ee){
ee.printStackTrace();
}
sos.flush();
sos.close();
br.close();
isr.close();
fis.close();
我在每行后面都加了 "\n ",可惜,在下载后的文本文件中,并没有换行,只是将换行符换成了个黑色方块状的东西
麻烦高手指点下
------解决方案--------------------
用\n\r试一试,不同的系统换行不一样~