From 4c7296d45efe849dc70a3b2e2240c905481a91c9 Mon Sep 17 00:00:00 2001
From: yangys <y_ys79@sina.com>
Date: 星期一, 29 九月 2025 17:44:46 +0800
Subject: [PATCH] 工控网涉密网联调

---
 blade-service/blade-mdm/src/main/java/org/springblade/mdm/utils/FileContentUtil.java |   25 ++++++++++++++++++++-----
 1 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/blade-service/blade-mdm/src/main/java/org/springblade/mdm/utils/FileContentUtil.java b/blade-service/blade-mdm/src/main/java/org/springblade/mdm/utils/FileContentUtil.java
index 7aef091..b3fa140 100644
--- a/blade-service/blade-mdm/src/main/java/org/springblade/mdm/utils/FileContentUtil.java
+++ b/blade-service/blade-mdm/src/main/java/org/springblade/mdm/utils/FileContentUtil.java
@@ -104,11 +104,10 @@
 		byte[] buffer = new byte[2048];
 		try {
 			int actRead = inputStream.read(buffer);
-
 			detector.handleData(buffer, 0, actRead);
-
 			//璇嗗埆缁撴潫蹇呴』璋冪敤杩欎釜鏂规硶
 			detector.dataEnd();
+			detector.reset();
 		} catch (IOException e) {
 			throw new RuntimeException(e);
 		}
@@ -159,10 +158,10 @@
 	/**
 	 * 鏇挎崲鏂囦欢涓殑鏌愪竴琛�
 	 * @param ins 杈撳叆娴�
-	 * @param repalceWith 鏇挎崲鍚庣殑鏂囨湰
+	 * @param replaceWith 鏇挎崲鐨勬枃鏈�
 	 * @param lineIndex 琛岀储寮� 0 based
 	 */
-    public static InputStream replaceAtLine(InputStream ins, int lineIndex,String repalceWith) throws IOException {
+    public static InputStream replaceAtLine(InputStream ins, int lineIndex,String replaceWith) throws IOException {
 		byte[] bytes = ins.readAllBytes();
 		ByteArrayInputStream byteStream = new ByteArrayInputStream(bytes);
 		Charset charset = Charsets.charset(detectFromInputStream(byteStream));
@@ -180,7 +179,7 @@
 			while ((line = reader.readLine()) != null) {
 				// 濡傛灉鏄洰鏍囪锛屽啓鍏ユ柊鍐呭
 				if (currentLine == lineIndex) {
-					writer.write(repalceWith);
+					writer.write(replaceWith);
 				} else {
 					writer.write(line);
 				}
@@ -191,4 +190,20 @@
 		}
 		return new ByteArrayInputStream(Files.newInputStream(tempFile).readAllBytes());
     }
+
+	public static List<String> readFirstNLines(InputStream inputStream, int n) throws IOException {
+		List<String> lines = new ArrayList<>();
+
+		try (BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))) {
+			String line;
+			int count = 0;
+
+			while ((line = reader.readLine()) != null && count < n) {
+				lines.add(line);
+				count++;
+			}
+		}
+
+		return lines;
+	}
 }

--
Gitblit v1.9.3