X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Futils%2FIOUtils.java;h=e7ab4033a8e15933ee6b38673a57efb6f074feb6;hb=9a85c386a8d7407b293b8520c2f7b538afa59045;hp=5a7e179b684d9423182c048376f2bf014c54077b;hpb=8e76f6ab13a8a4a651f2518b6c91d5e6424c7922;p=fanfix.git diff --git a/src/be/nikiroo/utils/IOUtils.java b/src/be/nikiroo/utils/IOUtils.java index 5a7e179..e7ab403 100644 --- a/src/be/nikiroo/utils/IOUtils.java +++ b/src/be/nikiroo/utils/IOUtils.java @@ -56,7 +56,7 @@ public class IOUtils { throws IOException { byte buffer[] = new byte[4096]; int len = in.read(buffer); - while (len > 0) { + while (len > -1) { out.write(buffer, 0, len); len = in.read(buffer); } @@ -232,7 +232,7 @@ public class IOUtils { throws IOException { FileOutputStream out = new FileOutputStream(file); try { - out.write(content.getBytes("UTF-8")); + out.write(StringUtils.getBytes(content)); } finally { out.close(); } @@ -275,8 +275,7 @@ public class IOUtils { write(stream, out); return out.toString("UTF-8"); } finally { - // do NOT close, or the related stream will be closed, too - // out.close(); + out.close(); } } @@ -410,19 +409,11 @@ public class IOUtils { write(in, tmp); in.close(); - final FileInputStream fis = new FileInputStream(tmp); - return new MarkableFileInputStream(fis) { + return new MarkableFileInputStream(tmp) { @Override public void close() throws IOException { try { - try { - super.close(); - } finally { - try { - fis.close(); - } catch (IOException e) { - } - } + super.close(); } finally { tmp.delete(); }