From 2cbfb12b0bd6fed7d82e0bb049ee72e749fda674 Mon Sep 17 00:00:00 2001 From: "Christian P. MOMON" Date: Thu, 12 Aug 2010 01:07:50 +0200 Subject: [PATCH] Fix input while. --- .../kiss4web/SimpleServletDispatcher.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/fr/devinsy/kiss4web/SimpleServletDispatcher.java b/src/fr/devinsy/kiss4web/SimpleServletDispatcher.java index 7cadc04..efbdfef 100644 --- a/src/fr/devinsy/kiss4web/SimpleServletDispatcher.java +++ b/src/fr/devinsy/kiss4web/SimpleServletDispatcher.java @@ -247,13 +247,22 @@ public class SimpleServletDispatcher extends HttpServlet FileInputStream in = null; try // Only for the in. { - byte[] buffer = new byte[256*1024]; + byte[] buffer = new byte[64*1024]; in = new FileInputStream(file); - - while (in.read(buffer) != -1) + boolean ended = false; + while (!ended) { - out.write(buffer); + int count = in.read(buffer); + + if (count == -1) + { + ended = true; + } + else + { + out.write(buffer, 0, count); + } } out.flush(); out.close();