From a06112f2ed25788cddc2dbb740e8760aa4d15a75 Mon Sep 17 00:00:00 2001 From: Aleksandr Skoblikov Date: Thu, 26 Oct 2023 15:43:06 +0200 Subject: [PATCH] CB-4125 improve file reading --- .../src/io/cloudbeaver/service/fs/impl/WebServiceFS.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/server/bundles/io.cloudbeaver.service.fs/src/io/cloudbeaver/service/fs/impl/WebServiceFS.java b/server/bundles/io.cloudbeaver.service.fs/src/io/cloudbeaver/service/fs/impl/WebServiceFS.java index c6c74adc3d..a6758c604c 100644 --- a/server/bundles/io.cloudbeaver.service.fs/src/io/cloudbeaver/service/fs/impl/WebServiceFS.java +++ b/server/bundles/io.cloudbeaver.service.fs/src/io/cloudbeaver/service/fs/impl/WebServiceFS.java @@ -26,6 +26,7 @@ import org.jkiss.dbeaver.registry.fs.FileSystemProviderRegistry; import java.net.URI; +import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; @@ -86,8 +87,10 @@ public FSFile[] getFiles(@NotNull WebSession webSession, @NotNull String project public String readFileContent(@NotNull WebSession webSession, @NotNull String projectId, @NotNull URI fileUri) throws DBWebException { try { - Path filePath = webSession.getFileSystemManager(projectId).getPathFromURI(webSession.getProgressMonitor(), fileUri); - return Files.readString(filePath); + Path filePath = webSession.getFileSystemManager(projectId) + .getPathFromURI(webSession.getProgressMonitor(), fileUri); + var data = Files.readAllBytes(filePath); + return new String(data, StandardCharsets.UTF_8); } catch (Exception e) { throw new DBWebException("Failed to read file content: " + e.getMessage(), e); }