wolfboys commented on code in PR #2979:
URL:
https://github.com/apache/incubator-streampark/pull/2979#discussion_r1306358429
##########
streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/base/util/FileUtils.java:
##########
@@ -73,4 +82,30 @@ public static byte[] readFileFromOffset(File file, long
startOffset, long maxSiz
}
return fileContent;
}
+
+ /**
+ * Roll View Log.
+ *
+ * @param path The file path.
+ * @param offset The offset.
+ * @param limit The limit.
+ * @return The content of the file.
+ * @throws ApiDetailException if there's an error rolling the view log.
+ */
+ public static String rollViewLog(String path, int offset, int limit) {
+ try {
+ File file = new File(path);
+ if (file.exists() && file.isFile()) {
+ try (Stream<String> stream = Files.lines(Paths.get(path))) {
+ List<String> lines =
stream.skip(offset).limit(limit).collect(Collectors.toList());
+ StringBuilder builder = new StringBuilder();
+ lines.forEach(line -> builder.append(line).append("\r\n"));
+ return builder.toString();
Review Comment:
The code can be further improved and simplified:
return stream.skip(offset).limit(limit).collect(Collectors.joining("\r\n"));
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]