From a4637fcf99dabad0f13650f01d4a383eb3427f13 Mon Sep 17 00:00:00 2001 From: mafagafogigante Date: Sat, 8 Nov 2014 20:35:23 -0200 Subject: [PATCH] Uses a StringBuilder to improve performance. Also stops initializing a variable (removes an unused initialization). --- .../src/main/java/com/iluwatar/FileLoader.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/model-view-presenter/src/main/java/com/iluwatar/FileLoader.java b/model-view-presenter/src/main/java/com/iluwatar/FileLoader.java index ec4d095da..c36dca612 100644 --- a/model-view-presenter/src/main/java/com/iluwatar/FileLoader.java +++ b/model-view-presenter/src/main/java/com/iluwatar/FileLoader.java @@ -29,17 +29,17 @@ public class FileLoader { try { BufferedReader br = new BufferedReader(new FileReader(new File( this.fileName))); - String text = ""; - String line = ""; + StringBuilder sb = new StringBuilder(); + String line; while ((line = br.readLine()) != null) { - text += line + "\n"; + sb.append(line).append('\n'); } this.loaded = true; br.close(); - return text; + return sb.toString(); } catch (Exception e) {