FlushedInputStream.java :  » Image » musician-slideshow » com » hugegreenbug » msoss » Android Open Source

Android Open Source » Image » musician slideshow 
musician slideshow » com » hugegreenbug » msoss » FlushedInputStream.java
package com.hugegreenbug.msoss;

import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;

  //Taken From: http://code.google.com/p/android/issues/detail?id=6066
   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;
        }
    }

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.