From 2df49d32a71818227e80a8628688906f2ede8a6a Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Tue, 2 Sep 2014 20:56:03 +0400 Subject: java-decompiler: fixes and cleanups - unified attribute loading code - common methods for checking member flags - verifying skip() - correct resource closing - typos --- .../java/decompiler/util/DataInputFullStream.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'src/org/jetbrains/java/decompiler/util/DataInputFullStream.java') diff --git a/src/org/jetbrains/java/decompiler/util/DataInputFullStream.java b/src/org/jetbrains/java/decompiler/util/DataInputFullStream.java index 0ed20dc..79e8c1d 100644 --- a/src/org/jetbrains/java/decompiler/util/DataInputFullStream.java +++ b/src/org/jetbrains/java/decompiler/util/DataInputFullStream.java @@ -25,20 +25,19 @@ public class DataInputFullStream extends DataInputStream { super(in); } - public final int readFull(byte[] b) throws IOException { - + public int readFull(byte[] b) throws IOException { int length = b.length; - byte[] btemp = new byte[length]; + byte[] temp = new byte[length]; int pos = 0; - int bytes_read = -1; + int bytes_read; while (true) { - bytes_read = read(btemp, 0, length - pos); + bytes_read = read(temp, 0, length - pos); if (bytes_read == -1) { return -1; } - System.arraycopy(btemp, 0, b, pos, bytes_read); + System.arraycopy(temp, 0, b, pos, bytes_read); pos += bytes_read; if (pos == length) { break; @@ -47,4 +46,10 @@ public class DataInputFullStream extends DataInputStream { return length; } + + public void discard(int n) throws IOException { + if (super.skip(n) != n) { + throw new IOException("Skip failed"); + } + } } -- cgit v1.2.3