git://git.nikiroo.be
/
nikiroo-utils.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
changelog.md
[nikiroo-utils.git]
/
src
/
be
/
nikiroo
/
utils
/
IOUtils.java
diff --git
a/src/be/nikiroo/utils/IOUtils.java
b/src/be/nikiroo/utils/IOUtils.java
index 5a7e179b684d9423182c048376f2bf014c54077b..e7ab4033a8e15933ee6b38673a57efb6f074feb6 100644
(file)
--- 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);
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);
}
out.write(buffer, 0, len);
len = in.read(buffer);
}
@@
-232,7
+232,7
@@
public class IOUtils {
throws IOException {
FileOutputStream out = new FileOutputStream(file);
try {
throws IOException {
FileOutputStream out = new FileOutputStream(file);
try {
- out.write(
content.getBytes("UTF-8"
));
+ out.write(
StringUtils.getBytes(content
));
} finally {
out.close();
}
} finally {
out.close();
}
@@
-275,8
+275,7
@@
public class IOUtils {
write(stream, out);
return out.toString("UTF-8");
} finally {
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();
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 {
@Override
public void close() throws IOException {
try {
- try {
- super.close();
- } finally {
- try {
- fis.close();
- } catch (IOException e) {
- }
- }
+ super.close();
} finally {
tmp.delete();
}
} finally {
tmp.delete();
}