diff options
| author | doufenghu <[email protected]> | 2024-06-15 23:58:07 +0800 |
|---|---|---|
| committer | doufenghu <[email protected]> | 2024-06-15 23:58:07 +0800 |
| commit | 7fee2660f82e0b73f3a93a790e9c4aacccb73c00 (patch) | |
| tree | c7435d8c4e444352a7e57cd68d9e2d7ed3ef224a /groot-common | |
| parent | 691f7172a5ce463ca565b744d6c68f173427a6ca (diff) | |
[Improve][knowledgeBase] Improve readFileFromLocalPath method that handles cases where the file path not contain a trailing slash ("/").
Diffstat (limited to 'groot-common')
| -rw-r--r-- | groot-common/src/main/java/com/geedgenetworks/common/utils/FileUtils.java | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/groot-common/src/main/java/com/geedgenetworks/common/utils/FileUtils.java b/groot-common/src/main/java/com/geedgenetworks/common/utils/FileUtils.java index 6796514..92b6f6a 100644 --- a/groot-common/src/main/java/com/geedgenetworks/common/utils/FileUtils.java +++ b/groot-common/src/main/java/com/geedgenetworks/common/utils/FileUtils.java @@ -191,10 +191,10 @@ public class FileUtils { return filePath.substring(filePath.lastIndexOf(File.separatorChar) + 1); } + @Deprecated public static byte[] getFileFromDir(String filePath) { try (BufferedInputStream bis = new BufferedInputStream(Files.newInputStream(Paths.get(filePath))); ByteArrayOutputStream baos = new ByteArrayOutputStream()) { - byte[] buffer = new byte[1024]; int bytesRead; while ((bytesRead = bis.read(buffer)) != -1) { @@ -204,7 +204,7 @@ public class FileUtils { } catch (Exception e) { String errorMsg = String.format("get local file [%s] failed", filePath); throw new GrootStreamRuntimeException( - CommonErrorCode.UNSUPPORTED_OPERATION, errorMsg, e); + CommonErrorCode.FILE_OPERATION_ERROR, errorMsg, e); } } } |
