From 8f131a0129f9262943d3104b032b9c6db9a662a8 Mon Sep 17 00:00:00 2001 From: dymik739 Date: Thu, 16 Mar 2023 09:27:02 +0200 Subject: [PATCH] reduce memory usage while reading help file --- labs/2/Main.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/labs/2/Main.java b/labs/2/Main.java index 13a03d6..854c09e 100644 --- a/labs/2/Main.java +++ b/labs/2/Main.java @@ -10,7 +10,6 @@ import java.io.BufferedInputStream; import java.io.FileOutputStream; public class Main { - public static void main(String[] args) { boolean help_enqueued = false; boolean allow_networking = true; @@ -80,14 +79,12 @@ public class Main { } Scanner help_file_scanner = new Scanner(help_file); - String help_text = ""; - + while (help_file_scanner.hasNextLine()) { - help_text += help_file_scanner.nextLine(); + System.out.print(help_file_scanner.nextLine()); } help_file_scanner.close(); - System.out.println(help_text); } catch (Exception e) { System.out.println("[ERROR] Failed to read help due to the following exception: " + e); System.exit(1);