X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fxwt%2Futil%2FCachedInputStream.java;h=d46569e8fb7e414a3eba81902287a2176296eba9;hb=68121b2887b78e1a99a55aa1bd7e428472518a6e;hp=fdf8a78ce4cb9bb2f95c1d64791fa519eae58cfc;hpb=856a577228c911de5e878cbc1aff88bde177a420;p=org.ibex.core.git diff --git a/src/org/xwt/util/CachedInputStream.java b/src/org/xwt/util/CachedInputStream.java index fdf8a78..d46569e 100644 --- a/src/org/xwt/util/CachedInputStream.java +++ b/src/org/xwt/util/CachedInputStream.java @@ -34,10 +34,11 @@ public class CachedInputStream { notifyAll(); } - private class SubStream extends InputStream { + private class SubStream extends InputStream implements KnownLength { int pos = 0; public int available() { return Math.max(0, size - pos); } public long skip(long n) throws IOException { pos += (int)n; return n; } // FEATURE: don't skip past EOF + public int getLength() { return eof ? size : is instanceof KnownLength ? ((KnownLength)is).getLength() : 0; } public int read() throws IOException { // FEATURE: be smarter here byte[] b = new byte[1]; int ret = read(b, 0, 1);