summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/org/jetbrains/java/decompiler/util/InterpreterUtil.java17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/org/jetbrains/java/decompiler/util/InterpreterUtil.java b/src/org/jetbrains/java/decompiler/util/InterpreterUtil.java
index 0047bb7..0644b69 100644
--- a/src/org/jetbrains/java/decompiler/util/InterpreterUtil.java
+++ b/src/org/jetbrains/java/decompiler/util/InterpreterUtil.java
@@ -70,14 +70,21 @@ public class InterpreterUtil {
}
private static byte[] readAndClose(InputStream stream, long length) throws IOException {
+
try {
- byte[] bytes = new byte[(int)length];
- if (stream.read(bytes) != length) {
- throw new IOException("premature end of stream");
+ byte[] bytes = new byte[(int) length];
+ DataInputStream dataStream = new DataInputStream(stream);
+
+ try {
+ dataStream.readFully(bytes);
+ } catch (EOFException ex) {
+ throw new IOException("premature end of stream", ex);
+ } finally {
+ dataStream.close();
}
+
return bytes;
- }
- finally {
+ } finally {
stream.close();
}
}