From ed8c7a5effd0d423ce1118b680ecdca6fe732609 Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期三, 02 七月 2025 16:43:13 +0800 Subject: [PATCH] Merge branch 'master' of http://192.168.11.205:9000/r/P2022036_Service --- src/main/java/com/lf/server/helper/FileHelper.java | 39 +++++++++++++++++++++++++++++---------- 1 files changed, 29 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/lf/server/helper/FileHelper.java b/src/main/java/com/lf/server/helper/FileHelper.java index 5c3f682..c9a5294 100644 --- a/src/main/java/com/lf/server/helper/FileHelper.java +++ b/src/main/java/com/lf/server/helper/FileHelper.java @@ -14,7 +14,6 @@ import java.security.MessageDigest; import java.text.DecimalFormat; import java.util.List; -import java.util.Objects; /** * 鏂囦欢甯姪绫� @@ -25,9 +24,6 @@ /** * 鑾峰彇鏂囦欢鍚� - * - * @param file - * @return */ public static String getFileName(String file) { int idx = file.lastIndexOf(File.separator); @@ -36,6 +32,19 @@ } return ""; + } + + /** + * 鑾峰彇鏂囦欢鍚嶇О + */ + public static String getName(String file) { + String fileName = getFileName(file); + int idx = fileName.lastIndexOf("."); + if (idx > -1) { + return fileName.substring(0, idx); + } + + return fileName; } /** @@ -74,9 +83,6 @@ /** * 鑾峰彇澶氱敤閫斾簰鑱旂綉閭欢鎵╁睍绫诲瀷 - * - * @param ext 鏂囦欢鎵╁睍鍚� - * @return */ public static String getMime(String ext) { switch (ext) { @@ -199,6 +205,19 @@ double tbNumber = gbNumber / StaticData.D1024; return new DecimalFormat("#.##TB").format(tbNumber); + } + + /** + * 鑾峰彇骞虫柟绫� + */ + public static String getSquareMeter(double num) { + if (num < StaticData.I1000000) { + return new DecimalFormat("#.##骞虫柟绫�").format(num); + } + + double knum = num / StaticData.I1000000; + + return new DecimalFormat("#.##骞虫柟鍗冪背").format(knum); } /** @@ -402,7 +421,7 @@ /** * 鏍规嵁璺緞鑾峰彇鏂囦欢 */ - public static void getFilesByPath(List<File> list, String path) { + public static void getFilesByPath(List<String> list, String path) { File file = new File(path); if (file.isDirectory()) { File[] files = file.listFiles(); @@ -414,11 +433,11 @@ if (f.isDirectory()) { getFilesByPath(list, f.getPath()); } else { - list.add(f); + list.add(f.getPath()); } } } else { - list.add(file); + list.add(file.getPath()); } } -- Gitblit v1.9.3