aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org/eclipse/jgit/util/TemporaryBuffer.java
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/util/TemporaryBuffer.java')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/util/TemporaryBuffer.java10
1 files changed, 2 insertions, 8 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/TemporaryBuffer.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/TemporaryBuffer.java
index dd933a0294..887f69b87c 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/TemporaryBuffer.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/TemporaryBuffer.java
@@ -487,11 +487,8 @@ public abstract class TemporaryBuffer extends OutputStream {
if (Integer.MAX_VALUE < len)
throw new OutOfMemoryError(JGitText.get().lengthExceedsMaximumArraySize);
final byte[] out = new byte[(int) len];
- final FileInputStream in = new FileInputStream(onDiskFile);
- try {
+ try (FileInputStream in = new FileInputStream(onDiskFile)) {
IO.readFully(in, out, 0, (int) len);
- } finally {
- in.close();
}
return out;
}
@@ -505,16 +502,13 @@ public abstract class TemporaryBuffer extends OutputStream {
}
if (pm == null)
pm = NullProgressMonitor.INSTANCE;
- final FileInputStream in = new FileInputStream(onDiskFile);
- try {
+ try (FileInputStream in = new FileInputStream(onDiskFile)) {
int cnt;
final byte[] buf = new byte[Block.SZ];
while ((cnt = in.read(buf)) >= 0) {
os.write(buf, 0, cnt);
pm.update(cnt / 1024);
}
- } finally {
- in.close();
}
}