將字符轉換爲流,並且下載


		
InputStream in=new ByteArrayInputStream(result.getBytes());  	
request.setCharacterEncoding("UTF-8");
response.setContentType("application/octet-stream; charset=utf-8");
response.setHeader("Content-disposition", "attachment; filename="+bean.getThingCode()+".json");// 設定輸出文件頭
OutputStream os = response.getOutputStream();
byte[] bs = new byte[1024];
int len;
while ((len = in.read(bs)) != -1) {
	 os.write(bs, 0, len);
}
os.flush();
os.close();

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章