CountingInputStream.java 1.75 KB
package com.google.common.io;

import com.google.common.annotations.Beta;
import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;
import javax.annotation.Nullable;

@Beta
public final class CountingInputStream
  extends FilterInputStream
{
  private long a;
  private long b = -1L;
  
  public CountingInputStream(@Nullable InputStream paramInputStream)
  {
    super(paramInputStream);
  }
  
  public final long getCount()
  {
    return this.a;
  }
  
  public final void mark(int paramInt)
  {
    try
    {
      this.in.mark(paramInt);
      this.b = this.a;
      return;
    }
    finally
    {
      localObject = finally;
      throw ((Throwable)localObject);
    }
  }
  
  public final int read()
    throws IOException
  {
    int i = this.in.read();
    if (i != -1) {
      this.a += 1L;
    }
    return i;
  }
  
  public final int read(byte[] paramArrayOfByte, int paramInt1, int paramInt2)
    throws IOException
  {
    paramInt1 = this.in.read(paramArrayOfByte, paramInt1, paramInt2);
    if (paramInt1 != -1) {
      this.a += paramInt1;
    }
    return paramInt1;
  }
  
  public final void reset()
    throws IOException
  {
    try
    {
      if (!this.in.markSupported()) {
        throw new IOException("Mark not supported");
      }
    }
    finally {}
    if (this.b == -1L) {
      throw new IOException("Mark not set");
    }
    this.in.reset();
    this.a = this.b;
  }
  
  public final long skip(long paramLong)
    throws IOException
  {
    paramLong = this.in.skip(paramLong);
    this.a += paramLong;
    return paramLong;
  }
}


/* Location:              /home/merong/decompile/hackery-dex2jar.jar!/com/google/common/io/CountingInputStream.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */