code cleanup, fix for ReplaceInputStream
[nikiroo-utils.git] / src / be / nikiroo / utils / IOUtils.java
index 5a7e179b684d9423182c048376f2bf014c54077b..fa18d0de5c868f411d2d7da88e2cf39fd0e47f23 100644 (file)
@@ -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);
                }
@@ -410,19 +410,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();
                                        }