--- dao/DaoAdresseService/src/dk/daoas/daoadresseservice/util/HttpUtil.java 2015/02/18 07:56:02 2325 +++ dao/DaoAdresseService/src/dk/daoas/daoadresseservice/util/HttpUtil.java 2015/02/18 21:30:17 2326 @@ -137,20 +137,16 @@ static byte[] readInputStream(InputStream is) throws IOException{ byte buffer[] = new byte[1024]; - ByteArrayOutputStream baos = new ByteArrayOutputStream(32768); //start buffer size - instead of default 32bytes - try { + //try /; //start buffer size - instead of default 32bytes + try (ByteArrayOutputStream baos = new ByteArrayOutputStream(32768)) { int count; + while ( (count = is.read(buffer)) != -1) { baos.write(buffer, 0, count); } - } finally { - try { - is.close(); - baos.close(); - } catch (Exception e) {} //never mind if close throws an exception - } - - return baos.toByteArray(); + is.close(); + return baos.toByteArray(); + } } }