From 44126aa4773a6d2fe1907e30f4a945b87f2b588d Mon Sep 17 00:00:00 2001 From: TudbuT Date: Fri, 29 Jul 2022 17:47:58 +0200 Subject: [PATCH] fix file reading --- .../tudbut/tryumph/server/BrowserContext.java | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/de/tudbut/tryumph/server/BrowserContext.java b/src/de/tudbut/tryumph/server/BrowserContext.java index c6ca0bd..df0ee36 100644 --- a/src/de/tudbut/tryumph/server/BrowserContext.java +++ b/src/de/tudbut/tryumph/server/BrowserContext.java @@ -152,13 +152,13 @@ public class BrowserContext { return builder.toString(); } stream = new FileInputStream(file); - int i = 0; - while((i = stream.read()) != -1) { - builder.append((char) i); - } - - stream.close(); } + int i = 0; + while((i = stream.read()) != -1) { + builder.append((char) i); + } + + stream.close(); if(!TryConfig.nocache) cache.put(file, builder.toString()); @@ -187,17 +187,18 @@ public class BrowserContext { return builder.toString(); } stream = new FileInputStream(file); - ByteArrayOutputStream s = new ByteArrayOutputStream(); - - int i = 0; - while((i = stream.read()) != -1) { - s.write(i); - } - - stream.close(); - s.close(); - st = new String(s.toByteArray()); } + ByteArrayOutputStream s = new ByteArrayOutputStream(); + + int i = 0; + while((i = stream.read()) != -1) { + s.write(i); + } + + stream.close(); + s.close(); + st = new String(s.toByteArray()); + if(!TryConfig.nocache) cache.put(file, st); } catch (IOException e) {