爲什麼下載文件文件名太長就會被截取,但是用就不會有文件名超長的問題?!

<span style="font-size:14px;">File file = new File(filePath);
		try {
			InputStream fis = new BufferedInputStream(new FileInputStream(file));
			byte[] buffer = new byte[fis.available()];
			fis.read(buffer);
			fis.close();
			ServletActionContext.getResponse().addHeader("Content-Disposition", "attachment;filename="+filename);
			ServletActionContext.getResponse().addHeader("Content-Length", "" + file.length());
			ServletActionContext.getResponse().setContentType("application/vnd.ms-excel");
			OutputStream os = new BufferedOutputStream(ServletActionContext.getResponse().getOutputStream());
			os.write(buffer);
			os.flush();
			os.close();
			
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}</span>

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