Skip to content

Commit

Permalink
CB-4125 improve file reading
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-skoblikov committed Oct 26, 2023
1 parent 39eddf0 commit a06112f
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit a06112f

Please sign in to comment.