Back to project page webimageloader.
The source code is released under:
Apache License
If you think the Android project webimageloader listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.webimageloader.util; //from www . j a va2 s .com import java.io.FilterInputStream; import java.io.IOException; import java.io.InputStream; /** * A {@link FilterInputStream} that blocks until the requested number of bytes * have been read/skipped, or the end of the stream is reached. * <p> * This filter can be used as a work-around for <a * href="http://code.google.com/p/android/issues/detail?id=6066">Issue * #6066</a>. */ public class FlushedInputStream extends FilterInputStream { public FlushedInputStream(InputStream inputStream) { super(inputStream); } @Override public long skip(long n) throws IOException { long totalBytesSkipped = 0L; while (totalBytesSkipped < n) { long bytesSkipped = in.skip(n - totalBytesSkipped); if (bytesSkipped == 0L) { int b = read(); if (b < 0) { break; // we reached EOF } else { bytesSkipped = 1; // we read one byte } } totalBytesSkipped += bytesSkipped; } return totalBytesSkipped; } }