From f8bd1c406ef31027967c0cfa8c2f5f097ae93ec9 Mon Sep 17 00:00:00 2001
From: fwq <582742538@qq.com>
Date: 星期二, 07 十一月 2023 16:19:33 +0800
Subject: [PATCH] 群联系方式配置管理

---
 src/main/java/com/hx/util/DownFileUtil.java |   35 +++++++++++++++++++++++++++++++++++
 1 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/src/main/java/com/hx/util/DownFileUtil.java b/src/main/java/com/hx/util/DownFileUtil.java
index 28542ac..a6535b0 100644
--- a/src/main/java/com/hx/util/DownFileUtil.java
+++ b/src/main/java/com/hx/util/DownFileUtil.java
@@ -187,4 +187,39 @@
 		}
 	}
 
+	/**
+	 * 涓嬭浇鏂囦欢宸ュ叿锛堟彁绀洪�夋嫨璺緞锛�
+	 *
+	 * @param downfile
+	 *            瀵煎嚭鐨勬枃浠�
+	 * @param fileName
+	 *            瀵煎嚭鐨勬枃浠跺悕绉�
+	 */
+	public static void DownFileTips( HttpServletResponse response, File downfile, String fileName) {
+		try {
+			if(StringUtils.isEmpty(fileName)){
+				fileName = downfile.getName();
+			}
+			String filename =  "";
+			filename = URLEncoder.encode(fileName,"UTF8");//鍏朵粬娴忚鍣�
+			InputStream fis = new BufferedInputStream(new FileInputStream(
+					downfile));
+			byte[] buffer = new byte[fis.available()];
+			fis.read(buffer);
+			fis.close();
+
+			response.addHeader("Content-Disposition", "attachment;filename="+ filename);
+			OutputStream toClient= new BufferedOutputStream(response.getOutputStream());
+			response.setContentType("application/vnd.ms-excel;charset=utf-8");
+
+			toClient.write(buffer);
+			toClient.flush();
+			toClient.close();
+		} catch (FileNotFoundException e) {
+			e.printStackTrace();
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+	}
+
 }

--
Gitblit v1.8.0