summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorRobin Rosenberg <robin.rosenberg@dewire.com>2010-02-03 16:42:07 -0500
committerCode Review <codereview-daemon@eclipse.org>2010-02-03 16:42:07 -0500
commitfbadb19543b1ad909bc57b46ff6a27af103934d4 (patch)
tree6e4a1a9d3ba25d051e5a5ccb755664e5a9f42d25 /org.eclipse.jgit
parentad94dca1ac2a5c9756aa099790524bdd086bdc2a (diff)
parentc581672557f0fb014babeb79c15d7f79fb206908 (diff)
downloadjgit-fbadb19543b1ad909bc57b46ff6a27af103934d4.tar.gz
jgit-fbadb19543b1ad909bc57b46ff6a27af103934d4.zip
Merge "Ensure RawText closes the FileInputStream when read is complete"
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/diff/RawText.java16
1 files changed, 2 insertions, 14 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/diff/RawText.java b/org.eclipse.jgit/src/org/eclipse/jgit/diff/RawText.java
index 9a206af190..c785534fbb 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/diff/RawText.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/diff/RawText.java
@@ -45,10 +45,10 @@
package org.eclipse.jgit.diff;
import java.io.File;
-import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
+import org.eclipse.jgit.util.IO;
import org.eclipse.jgit.util.IntList;
import org.eclipse.jgit.util.RawParseUtils;
@@ -99,7 +99,7 @@ public class RawText implements Sequence {
* @throws IOException if Exceptions occur while reading the file
*/
public RawText(File file) throws IOException {
- this(readFile(file));
+ this(IO.readFully(file));
}
public int size() {
@@ -202,16 +202,4 @@ public class RawText implements Sequence {
hash = (hash << 5) ^ (raw[ptr] & 0xff);
return hash;
}
-
- private static byte[] readFile(File file) throws IOException {
- byte[] result = new byte[(int)file.length()];
- FileInputStream in = new FileInputStream(file);
- for (int off = 0; off < result.length; ) {
- int read = in.read(result, off, result.length - off);
- if (read < 0)
- throw new IOException("Early EOF");
- off += read;
- }
- return result;
- }
}